18 lines
700 B
C#
18 lines
700 B
C#
namespace Brizco.Repository.Handlers.Routines;
|
|
|
|
public class GetRoutineQueryHandler(IRepositoryWrapper repositoryWrapper)
|
|
: IRequestHandler<GetRoutineQuery, RoutineSDto>
|
|
{
|
|
public async Task<RoutineSDto> Handle(GetRoutineQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var shift = await repositoryWrapper.SetRepository<Domain.Entities.Routines.Routine>()
|
|
.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;
|
|
}
|
|
} |