Api/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs

21 lines
802 B
C#

namespace Brizco.Repository.Handlers.ShiftPlan;
public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftPlansQuery, List<ShiftPlanSDto>>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<List<ShiftPlanSDto>> Handle(GetShiftPlansQuery request, CancellationToken cancellationToken)
{
var shifts = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.ShiftPlan>().TableNoTracking
.OrderByDescending(s => s.CreatedAt)
.Skip(request.Page * 15).Take(15)
.Select(ShiftPlanMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
return shifts;
}
}