コード例 #1
0
        public List <InterJetRoundTripFlight> GetRoundTripFlights()
        {
            List <InterJetRoundTripFlight> roundTrips = new List <InterJetRoundTripFlight>();

            foreach (InterJetFlight flightToCompare in this.Flights)
            {
                InterJetFlight departureFlight = this.Flights.Where(flight => flight.DepartureStation.Equals(flightToCompare.ArrivalStation) &&
                                                                    flight.ArrivalStation.Equals(flightToCompare.DepartureStation) &&
                                                                    flight.IvaTotal != flightToCompare.IvaTotal).FirstOrDefault();

                if (departureFlight != null)
                {
                    InterJetRoundTripFlight roundTrip = new InterJetRoundTripFlight {
                        DepartureFlight = departureFlight,
                        ArrivalFlight   = flightToCompare
                    };


                    bool roundTripExist = roundTrips.Where(r => r.Equals(roundTrip)).FirstOrDefault() != null;
                    if (!roundTripExist)
                    {
                        roundTrips.Add(roundTrip);
                    }
                    flightToCompare.IsRoundTrip = true;
                }
            }

            return(roundTrips);
        }
コード例 #2
0
        public bool Equals(InterJetRoundTripFlight roundTripToCompare)
        {
            bool IsValid = this.DepartureFlight.FareSellKey.Equals(roundTripToCompare.DepartureFlight.FareSellKey) ||
                           this.ArrivalFlight.FareSellKey.Equals(roundTripToCompare.DepartureFlight.FareSellKey) ||
                           this.DepartureFlight.FareSellKey.Equals(roundTripToCompare.ArrivalFlight.FareSellKey) ||
                           this.ArrivalFlight.FareSellKey.Equals(roundTripToCompare.ArrivalFlight.FareSellKey);

            return(IsValid);
        }