/// <summary> /// Loads the passengers into the list of passengers for this aircraft from based on the passenger flight link in the database /// </summary> public void LoadPassengers() { var query = from passenger in FlightController.GetAllPassengers() join link in FlightController.GetAllLinks() on passenger.ID equals link.Passenger_ID where link.Flight_ID == _flightInfo.Flight_ID select passenger; Passengers.AddRange(query); }
/// <summary> /// Which seats on this aircraft are filled /// </summary> /// <returns></returns> public IEnumerable <int> GetFilledSeats() { var query = from passenger in FlightController.GetAllPassengers() join link in FlightController.GetAllLinks() on passenger.ID equals link.Passenger_ID where link.Flight_ID == _flightInfo.Flight_ID select link; List <int> filledSeats = new List <int>(); foreach (FlightPassengerLink link in query) { filledSeats.Add(link.Seat_Number); } return(filledSeats); }
/// <summary> /// Determines the passengers seat number /// </summary> /// <param name="passenger"></param> /// <returns></returns> public string GetPassengerSeatID(Passenger passenger) { if (Passengers == null || passenger == null) { return(""); } var query = from pass in Passengers where pass.FirstName == passenger.FirstName && pass.LastName == passenger.LastName select pass; Passenger foundPassenger = query.ToList()[0]; var linkQuery = from passLink in FlightController.GetAllLinks() where passLink.Passenger_ID == foundPassenger.ID select passLink; return(linkQuery.ToList()[0].Seat_Number.ToString()); }