17 lines
706 B
C#
17 lines
706 B
C#
namespace Brizco.Repository.Handlers.ShiftPlans;
|
|
|
|
public class GetShiftPlanQueryHandler(IRepositoryWrapper repositoryWrapper)
|
|
: IRequestHandler<GetShiftPlanQuery, ShiftPlanLDto>
|
|
{
|
|
public async Task<ShiftPlanLDto> Handle(GetShiftPlanQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var shiftPlan = await repositoryWrapper.SetRepository<ShiftPlan>()
|
|
.TableNoTracking
|
|
.Where(s => s.Id == request.Id)
|
|
.Select(ShiftPlanMapper.ProjectToLDto)
|
|
.FirstOrDefaultAsync(cancellationToken);
|
|
if (shiftPlan == null)
|
|
throw new AppException("ShiftPlan not found", ApiResultStatusCode.NotFound);
|
|
return shiftPlan;
|
|
}
|
|
} |