2023-09-18 09:45:02 +03:30
|
|
|
|
namespace Brizco.Repository.Handlers.Shift;
|
|
|
|
|
|
|
2023-09-18 15:41:41 +03:30
|
|
|
|
public class GetShiftPlanQueryHandler : IRequestHandler<GetShiftQuery, ShiftSDto>
|
2023-09-18 09:45:02 +03:30
|
|
|
|
{
|
|
|
|
|
|
private readonly IRepositoryWrapper _repositoryWrapper;
|
|
|
|
|
|
|
2023-09-18 15:41:41 +03:30
|
|
|
|
public GetShiftPlanQueryHandler(IRepositoryWrapper repositoryWrapper)
|
2023-09-18 09:45:02 +03:30
|
|
|
|
{
|
|
|
|
|
|
_repositoryWrapper = repositoryWrapper;
|
|
|
|
|
|
}
|
|
|
|
|
|
public async Task<ShiftSDto> Handle(GetShiftQuery request, CancellationToken cancellationToken)
|
|
|
|
|
|
{
|
|
|
|
|
|
var shift = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.Shift>()
|
|
|
|
|
|
.TableNoTracking
|
|
|
|
|
|
.Where(s => s.Id == request.id)
|
|
|
|
|
|
.Select(ShiftMapper.ProjectToSDto)
|
|
|
|
|
|
.FirstOrDefaultAsync(cancellationToken);
|
2023-11-13 14:42:49 +03:30
|
|
|
|
|
2023-09-18 09:45:02 +03:30
|
|
|
|
if (shift == null)
|
|
|
|
|
|
throw new AppException("Shift not found", ApiResultStatusCode.NotFound);
|
|
|
|
|
|
return shift;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|