예제 #1
0
        public Guid Execute(long flightId, long passengerId, RegisterPassengerBagRequest passengerBagRequest)
        {
            var baggage = checkedInBaggageRepository.Get(flightId, passengerId)
                          ?? throw new BaggageNotFoundException(flightId, passengerId);

            var bagDto = passengerBagRequest.Bag;

            var bagGuid = baggage.CheckIn(bagDto.Weight);

            checkedInBaggageRepository.Save(baggage);

            return(bagGuid);
        }
        public Guid Execute(long flightId, StartPassengerRegistrationRequest passengerRequest)
        {
            var flight = flightRepository.GetById(flightId)
                         ?? throw new FlightNotFoundException(flightId);

            var passengerId = passengerRequest.Passenger.Id;
            var passenger   = passengerRepository.GetById(passengerId)
                              ?? throw new PassengerNotFoundException(passengerId);

            var baggageLimits = baggageLimitsRepository.GetByServiceClass(flight.FlightNumber, passenger.ServiceClass);
            //TODO: consider creating in Flight / factory
            //TODO: can be used to implement baggage reservation
            var emptyBaggage = new PassengerBaggage(flight, passenger, baggageLimits);

            var boardingPassGuid = flight.CheckIn(passenger);

            //Transactional
            flightRepository.Save(flight);
            baggageRepository.Save(emptyBaggage);

            return(boardingPassGuid);
        }