Spaces:
Running
Running
Download FlowAPI.Infrastructure/Repositories/SharedGraphRepository.cs from DanilDrotik/FlowAPI: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/spaces/DanilDrotik/FlowAPI/resolve/d8ea1e09beb0ef2cedc523cc8585fea6cc52c013/FlowAPI.Infrastructure/Repositories/SharedGraphRepository.cs
- Command line
-
hf download hf://spaces/DanilDrotik/FlowAPI@d8ea1e09beb0ef2cedc523cc8585fea6cc52c013/FlowAPI.Infrastructure/Repositories/SharedGraphRepository.cs
-
curl -L -o SharedGraphRepository.cs https://huggingface.co/spaces/DanilDrotik/FlowAPI/resolve/d8ea1e09beb0ef2cedc523cc8585fea6cc52c013/FlowAPI.Infrastructure/Repositories/SharedGraphRepository.cs
1.28 kB
| using FlowAPI.Application.Interfaces; | |
| using FlowAPI.Domain.Entities; | |
| using FlowAPI.Infrastructure.Data; | |
| using Microsoft.EntityFrameworkCore; | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Threading.Tasks; | |
| namespace FlowAPI.Infrastructure.Repositories | |
| { | |
| public class SharedGraphRepository : GenericRepository<SharedGraph>, ISharedGraphRepository | |
| { | |
| public SharedGraphRepository(AppDbContext context) : base(context) { } | |
| public async Task<IEnumerable<SharedGraph>> GetSharedGraphsByUserIdAsync(Guid userId) | |
| { | |
| return await _dbSet | |
| .Include(s => s.Graph) | |
| .Where(s => s.SharedWithUserId == userId) | |
| .ToListAsync(); | |
| } | |
| public async Task<SharedGraph?> GetShareAsync(Guid graphId, Guid sharedWithUserId) | |
| { | |
| return await _dbSet | |
| .FirstOrDefaultAsync(s => s.GraphId == graphId && s.SharedWithUserId == sharedWithUserId); | |
| } | |
| public async Task<IEnumerable<SharedGraph>> GetSharesForGraphAsync(Guid graphId) | |
| { | |
| return await _dbSet | |
| .Include(s => s.SharedWithUser) | |
| .Where(s => s.GraphId == graphId) | |
| .ToListAsync(); | |
| } | |
| } | |
| } | |