Files
2026-03-17 09:53:09 -05:00

36 lines
1.3 KiB
C#

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<ICollection<UserAssignment>> GetAllUserAssignmentsAsync()
{
return await _context.UserAssignments.Include(x => x.AppUser).ToListAsync();
}
public async Task<UserAssignment> FindExistingAssignmentAsync(AssignmentType assignmentType, string key)
{
return await _context.UserAssignments
.Include(x => x.AppUser)
.FirstOrDefaultAsync(x => x.Type == assignmentType && x.Key == key);
}
public async Task<UserAssignment> IsUserAssigned(AssignmentType assignmentType, AppUser appUser)
{
return await _context.UserAssignments
.Include(x => x.AppUser)
.FirstOrDefaultAsync(x => x.Type == assignmentType
&& x.AppUser.EmployeeId == appUser.EmployeeId);
}
}