2023-09-15 12:37:02 +03:30
|
|
|
|
namespace Brizco.Repository.Handlers.Shift;
|
|
|
|
|
|
|
2023-09-18 15:41:41 +03:30
|
|
|
|
public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftsQuery, List<ShiftSDto>>
|
2023-09-15 12:37:02 +03:30
|
|
|
|
{
|
|
|
|
|
|
private readonly IRepositoryWrapper _repositoryWrapper;
|
|
|
|
|
|
|
2023-09-18 15:41:41 +03:30
|
|
|
|
public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper)
|
2023-09-15 12:37:02 +03:30
|
|
|
|
{
|
|
|
|
|
|
_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)
|
2023-09-18 09:45:02 +03:30
|
|
|
|
.Skip(request.page * 15).Take(15)
|
|
|
|
|
|
.Select(ShiftMapper.ProjectToSDto)
|
2023-09-15 12:37:02 +03:30
|
|
|
|
.ToListAsync(cancellationToken);
|
|
|
|
|
|
|
2023-10-26 01:24:04 +03:30
|
|
|
|
|
2023-09-15 12:37:02 +03:30
|
|
|
|
return shifts;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|