2024-05-27 00:35:53 +03:30
|
|
|
|
using Brizco.Domain.Dtos.LargeDtos;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Brizco.Repository.Handlers.Position;
|
2023-11-14 16:21:49 +03:30
|
|
|
|
|
|
|
|
|
|
public class GetPositionQueryHandler : IRequestHandler<GetPositionQuery, PositionLDto>
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IRepositoryWrapper _repositoryWrapper;
|
|
|
|
|
|
|
|
|
|
|
|
public GetPositionQueryHandler(IRepositoryWrapper repositoryWrapper)
|
|
|
|
|
|
{
|
|
|
|
|
|
_repositoryWrapper = repositoryWrapper;
|
|
|
|
|
|
}
|
|
|
|
|
|
public async Task<PositionLDto> Handle(GetPositionQuery request, CancellationToken cancellationToken)
|
|
|
|
|
|
{
|
|
|
|
|
|
var shift = await _repositoryWrapper.SetRepository<Domain.Entities.Complex.Position>()
|
|
|
|
|
|
.TableNoTracking
|
|
|
|
|
|
.Where(s => s.Id == request.Id)
|
|
|
|
|
|
.Select(PositionMapper.ProjectToLDto)
|
|
|
|
|
|
.FirstOrDefaultAsync(cancellationToken);
|
|
|
|
|
|
|
|
|
|
|
|
if (shift == null)
|
|
|
|
|
|
throw new AppException("Position not found", ApiResultStatusCode.NotFound);
|
|
|
|
|
|
return shift;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|