コード例 #1
0
ファイル: Aircraft.cs プロジェクト: KaydenMiller/CS3280_A6
        /// <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);
        }
コード例 #2
0
ファイル: Aircraft.cs プロジェクト: KaydenMiller/CS3280_A6
        /// <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);
        }
コード例 #3
0
ファイル: Aircraft.cs プロジェクト: KaydenMiller/CS3280_A6
        /// <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());
        }