23 lines
851 B
C#
23 lines
851 B
C#
namespace Brizco.Repository.Handlers.Routine;
|
|
|
|
public class GetRoutineQueryHandler : IRequestHandler<GetRoutineQuery, RoutineSDto>
|
|
{
|
|
private readonly IRepositoryWrapper _repositoryWrapper;
|
|
|
|
public GetRoutineQueryHandler(IRepositoryWrapper repositoryWrapper)
|
|
{
|
|
_repositoryWrapper = repositoryWrapper;
|
|
}
|
|
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;
|
|
}
|
|
} |