public ActionResult <Passenger> GetNotification(int passengerId)
        {
            var passenger = _passengerRepository.GetById(passengerId);

            if (passenger == null)
            {
                return(NotFound("Passenger not found"));
            }

            if (passenger.Notification == null)
            {
                return(NotFound("Passenger does not have a notifcation"));
            }

            return(Ok(passenger));
        }
Exemple #2
0
        public ActionResult <List <OrderDTO> > GetOrderHistory(int passengerId)
        {
            List <OrderDTO> allOrderDTOs = new List <OrderDTO>();
            Passenger       passenger    = _passengerRepository.GetById(passengerId);

            if (passenger == null)
            {
                return(NotFound("User not found"));
            }

            var orders = _orderRepository.RetrieveAllOrdersByUserId(passenger.UserId).ToList();

            if (orders == null)
            {
                return(NotFound("Orders not found"));
            }

            foreach (Order order in orders)
            {
                OrderDTO orderDTO = new OrderDTO(order);
                allOrderDTOs.Add(orderDTO);
            }

            return(Ok(allOrderDTOs));
        }
        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);
        }