21 lines
766 B
C#
21 lines
766 B
C#
namespace Brizco.Repository.Handlers.Shift;
|
|
|
|
public class GetShiftsQueryHandler : IRequestHandler<GetShiftsQuery, List<ShiftSDto>>
|
|
{
|
|
private readonly IRepositoryWrapper _repositoryWrapper;
|
|
|
|
public GetShiftsQueryHandler(IRepositoryWrapper repositoryWrapper)
|
|
{
|
|
_repositoryWrapper = repositoryWrapper;
|
|
}
|
|
public async Task<List<ShiftSDto>> Handle(GetShiftsQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var shifts = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.Shift>().TableNoTracking
|
|
.OrderByDescending(s => s.CreatedAt)
|
|
.Skip(request.page * 15).Take(15)
|
|
.Select(ShiftMapper.ProjectToSDto)
|
|
.ToListAsync(cancellationToken);
|
|
|
|
return shifts;
|
|
}
|
|
} |