23 lines
936 B
C#
23 lines
936 B
C#
namespace Brizco.Repository.Handlers.Shifts;
|
|
|
|
public class GetShiftPlanQueryHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler<GetShiftQuery, ShiftLDto>
|
|
{
|
|
public async Task<ShiftLDto> Handle(GetShiftQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var shift = await repositoryWrapper.SetRepository<Shift>()
|
|
.TableNoTracking
|
|
.Where(s => s.Id == request.Id)
|
|
.Select(ShiftMapper.ProjectToLDto)
|
|
.FirstOrDefaultAsync(cancellationToken);
|
|
|
|
if (shift == null)
|
|
throw new AppException("Shift not found", ApiResultStatusCode.NotFound);
|
|
//var shiftDays = await _repositoryWrapper.SetRepository<ShiftDay>()
|
|
// .TableNoTracking
|
|
// .Where(sd => sd.ShiftId == request.Id)
|
|
// .ToListAsync(cancellationToken);
|
|
//shift.Days = shiftDays.Select(s => s.DayOfWeek).ToList();
|
|
|
|
return shift;
|
|
}
|
|
} |