23 lines
829 B
C#
23 lines
829 B
C#
namespace Brizco.Repository.Handlers.Sections;
|
|
|
|
public class GetSectionQueryHandler : IRequestHandler<GetSectionQuery, SectionLDto>
|
|
{
|
|
private readonly IRepositoryWrapper _repositoryWrapper;
|
|
|
|
public GetSectionQueryHandler(IRepositoryWrapper repositoryWrapper)
|
|
{
|
|
_repositoryWrapper = repositoryWrapper;
|
|
}
|
|
public async Task<SectionLDto> Handle(GetSectionQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var shift = await _repositoryWrapper.SetRepository<Section>()
|
|
.TableNoTracking
|
|
.Where(s => s.Id == request.Id)
|
|
.Select(SectionMapper.ProjectToLDto)
|
|
.FirstOrDefaultAsync(cancellationToken);
|
|
|
|
if (shift == null)
|
|
throw new AppException("Section not found", ApiResultStatusCode.NotFound);
|
|
return shift;
|
|
}
|
|
} |