示例#1
0
        public ActionResult <Seat> GetAvailableSeats(string flightId)
        {
            List <Seat> seats = GetAllSeats(flightId);

            var passengers = _userFlightRepository.GetAllPassengersByFlightId(flightId).ToList();

            List <int> passengerSeatIds = passengers.Select(p => p.Seat.SeatId).ToList();

            seats.RemoveAll(s => passengerSeatIds.Contains(s.SeatId));

            return(Ok(seats));
        }
示例#2
0
        public ActionResult <List <Passenger> > GetPassengerById(string flightId)
        {
            var passengers = _userFlightRepository.GetAllPassengersByFlightId(flightId);

            if (passengers == null)
            {
                return(NotFound("Passengers not found"));
            }

            return(Ok(passengers));
        }
        public ActionResult <Notification> AddNotificationAllPassengers(string flightId, NotificationDTO model)
        {
            Notification notification = new Notification(model.Text, model.Type);

            _notificiationRepository.Add(notification);

            List <Passenger> passengers = _userFlightRepository.GetAllPassengersByFlightId(flightId).ToList();

            if (passengers == null)
            {
                return(NotFound("Flight not found"));
            }

            foreach (Passenger passenger in passengers)
            {
                passenger.Notification       = notification;
                passenger.IsNotificationRead = false;
            }

            _notificiationRepository.SaveChanges();
            _passengerRepository.SaveChanges();

            return(Ok());
        }