コード例 #1
0
        public async Task <Core.Domain.Passenger> Handle(GetPassengerByIdQuery request, CancellationToken cancellationToken)
        {
            var passenger = await _passengerRepository.GetAsync(request.PassengerId);

            if (passenger is null)
            {
                throw new ArgumentNullException($"Passenger with {request.PassengerId} not exist");
            }
            return(passenger);
        }
コード例 #2
0
        public static async Task <Passenger> GetOrFailAsync(this IPassengerRepository repository, Guid userId)
        {
            var passenger = await repository.GetAsync(userId);

            if (passenger == null)
            {
                throw new Exception($"Passenger with id '{userId}' doesn't exists.");
            }

            return(passenger);
        }
コード例 #3
0
        public async Task <PassengerDetailsDto> GetAsync(Guid userId)
        {
            var passenger = await _passengerRepository.GetAsync(userId);

            return(_mapper.Map <PassengerDetailsDto>(passenger));
        }