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, ISharedGraphRepository { public SharedGraphRepository(AppDbContext context) : base(context) { } public async Task> GetSharedGraphsByUserIdAsync(Guid userId) { return await _dbSet .Include(s => s.Graph) .Where(s => s.SharedWithUserId == userId) .ToListAsync(); } public async Task GetShareAsync(Guid graphId, Guid sharedWithUserId) { return await _dbSet .FirstOrDefaultAsync(s => s.GraphId == graphId && s.SharedWithUserId == sharedWithUserId); } public async Task> GetSharesForGraphAsync(Guid graphId) { return await _dbSet .Include(s => s.SharedWithUser) .Where(s => s.GraphId == graphId) .ToListAsync(); } } }