using System.Collections.Generic; using System.Threading.Tasks; using LCU.Library.Internal.IncentiveApiModels.Entities; using LCU.Library.Internal.IncentiveApiModels.Enums; using LCU.API.Internal.Operations.IncentiveApiLib.Persistence; using Microsoft.EntityFrameworkCore; namespace LCU.API.Internal.Operations.IncentiveApiLib.Repositories; public class UserAssignmentRepository : BaseRepository, IUserAssignmentRepository { public UserAssignmentRepository(IApplicationDbContext context) : base(context) { } public async Task> GetAllUserAssignmentsAsync() { return await _context.UserAssignments.Include(x => x.AppUser).ToListAsync(); } public async Task FindExistingAssignmentAsync(AssignmentType assignmentType, string key) { return await _context.UserAssignments .Include(x => x.AppUser) .FirstOrDefaultAsync(x => x.Type == assignmentType && x.Key == key); } public async Task IsUserAssigned(AssignmentType assignmentType, AppUser appUser) { return await _context.UserAssignments .Include(x => x.AppUser) .FirstOrDefaultAsync(x => x.Type == assignmentType && x.AppUser.EmployeeId == appUser.EmployeeId); } }