Api/Brizco.Repository/Handlers/Routines/GetRoutineQueryHandler.cs

18 lines
700 B
C#
Raw Permalink Normal View History

namespace Brizco.Repository.Handlers.Routines;
2023-11-14 16:21:49 +03:30
2024-08-09 21:42:04 +03:30
public class GetRoutineQueryHandler(IRepositoryWrapper repositoryWrapper)
: IRequestHandler<GetRoutineQuery, RoutineSDto>
2023-11-14 16:21:49 +03:30
{
public async Task<RoutineSDto> Handle(GetRoutineQuery request, CancellationToken cancellationToken)
{
2024-08-09 21:42:04 +03:30
var shift = await repositoryWrapper.SetRepository<Domain.Entities.Routines.Routine>()
2023-11-14 16:21:49 +03:30
.TableNoTracking
.Where(s => s.Id == request.Id)
.Select(RoutineMapper.ProjectToSDto)
.FirstOrDefaultAsync(cancellationToken);
if (shift == null)
throw new AppException("Shift not found", ApiResultStatusCode.NotFound);
return shift;
}
}