GetDestinationDemands() public method

public GetDestinationDemands ( ) : List
return List
        public AirportMVVM(Airport airport)
        {
            Airport = airport;

            TerminalGatePrice = Airport.GetTerminalGatePrice();
            TerminalPrice = Airport.GetTerminalPrice();
            LandingFee = GeneralHelpers.GetInflationPrice(Airport.LandingFee);
            FuelPrice = AirportHelpers.GetFuelPrice(Airport);

            TotalPaxGates = Airport.Terminals.AirportTerminals.Where(t=>t.Type == Terminal.TerminalType.Passenger).Sum(t=>t.Gates.NumberOfDeliveredGates);
            TotalCargoGates = Airport.Terminals.AirportTerminals.Where(t=>t.Type == Terminal.TerminalType.Cargo).Sum(t=>t.Gates.NumberOfDeliveredGates);

            Cooperations = new ObservableCollection<Cooperation>();
            Terminals = new ObservableCollection<AirportTerminalMVVM>();
            BuildingTerminals = new ObservableCollection<AirportTerminalMVVM>();

            foreach (Terminal terminal in Airport.Terminals.GetTerminals())
            {
                Boolean isSellable = terminal.Airline != null
                                     && terminal.Airline == GameObject.GetInstance().HumanAirline;

                if (terminal.IsBuilt)
                {
                    Terminals.Add(new AirportTerminalMVVM(terminal, terminal.IsBuyable, isSellable));
                }
                else
                {
                    BuildingTerminals.Add(new AirportTerminalMVVM(terminal, terminal.IsBuyable, isSellable));
                }
            }
            Contracts = new ObservableCollection<ContractMVVM>();

            foreach (AirportContract contract in Airport.AirlineContracts)
            {
                Contracts.Add(new ContractMVVM(contract));
            }

            foreach (Cooperation cooperation in Airport.Cooperations)
            {
                Cooperations.Add(cooperation);
            }

            AirportHelpers.CreateAirportWeather(Airport);

            Weather = Airport.Weather.ToList();

            if (!GameObject.GetInstance().DayRoundEnabled)
            {
                CurrentWeather = Weather[0].Temperatures[GameObject.GetInstance().GameTime.Hour];
            }

            FreeGates = Airport.Terminals.NumberOfFreeGates;

            FreeCargoGates = Airport.Terminals.AirportTerminals.Where(t=>t.Type == Terminal.TerminalType.Cargo).Sum(t=>t.GetFreeGates());

            FreePaxGates = Airport.Terminals.AirportTerminals.Where(t => t.Type == Terminal.TerminalType.Passenger).Sum(t => t.GetFreeGates());

            DomesticDemands = new List<DemandMVVM>();
            IntlDemands = new List<DemandMVVM>();

            IOrderedEnumerable<Airport> demands =
                Airport.GetDestinationDemands()
                    .Where(a => a != null && GeneralHelpers.IsAirportActive(a))
                    .OrderByDescending(
                        a => Airport.GetDestinationPassengersRate(a, AirlinerClass.ClassType.EconomyClass));

            IEnumerable<Airport> internationalDemand =
                demands.Where(
                    a =>
                        new CountryCurrentCountryConverter().Convert(a.Profile.Country)
                        != new CountryCurrentCountryConverter().Convert(Airport.Profile.Country));
            IEnumerable<Airport> domesticDemand =
                demands.Where(
                    a =>
                        new CountryCurrentCountryConverter().Convert(a.Profile.Country)
                        == new CountryCurrentCountryConverter().Convert(Airport.Profile.Country));

            foreach (Airport destination in internationalDemand)
            {
                IntlDemands.Add(
                    new DemandMVVM(
                        destination,
                        Airport.GetDestinationPassengersRate(destination, AirlinerClass.ClassType.EconomyClass),
                        (int)Airport.Profile.Pax,
                        Airport.GetDestinationCargoRate(destination),MathHelpers.GetDistance(destination,Airport)));
            }

            foreach (Airport destination in domesticDemand)
            {
                DomesticDemands.Add(
                    new DemandMVVM(
                        destination,
                        Airport.GetDestinationPassengersRate(destination, AirlinerClass.ClassType.EconomyClass),
                        (int)Airport.Profile.Pax,
                        Airport.GetDestinationCargoRate(destination), MathHelpers.GetDistance(destination,Airport)));
            }

            AirportFacilities =
                Airport.GetAirportFacilities()
                    .FindAll(f => f.Airline == null && f.Facility.TypeLevel != 0)
                    .Select(f => f.Facility)
                    .Distinct()
                    .ToList();

            AirlineFacilities = new ObservableCollection<AirlineAirportFacilityMVVM>();
            BuildingAirlineFacilities = new ObservableCollection<AirlineAirportFacilityMVVM>();

            foreach (
                AirlineAirportFacility facility in Airport.GetAirportFacilities().FindAll(f => f.Airline != null))
            {
                if (facility.Facility.TypeLevel != 0)
                {
                    Alliance alliance = facility.Airline.Alliances.Count == 0 ? null : facility.Airline.Alliances[0];

                    var airlineFacility = new AirlineAirportFacilityMVVM(facility, alliance);

                    if (airlineFacility.IsDelivered)
                    {
                        if (facility == Airport.GetAirlineAirportFacility(facility.Airline, facility.Facility.Type))
                        {
                            AirlineFacilities.Add(airlineFacility);
                        }
                    }
                    else
                    {
                        BuildingAirlineFacilities.Add(airlineFacility);
                    }
                }
            }

            AirlineStatistics = new List<AirportStatisticsMVMM>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                StatisticsType passengersType = StatisticsTypes.GetStatisticsType("Passengers");
                StatisticsType passengersAvgType = StatisticsTypes.GetStatisticsType("Passengers%");
                StatisticsType arrivalsType = StatisticsTypes.GetStatisticsType("Arrivals");

                double passengers = Airport.Statistics.GetStatisticsValue(
                    GameObject.GetInstance().GameTime.Year,
                    airline,
                    passengersType);
                double passengersAvg = Airport.Statistics.GetStatisticsValue(
                    GameObject.GetInstance().GameTime.Year,
                    airline,
                    passengersAvgType);
                double arrivals = Airport.Statistics.GetStatisticsValue(
                    GameObject.GetInstance().GameTime.Year,
                    airline,
                    arrivalsType);

                int routes = airline.Routes.Count(r => r.Destination1 == Airport || r.Destination2 == Airport);

                AirlineStatistics.Add(
                    new AirportStatisticsMVMM(airline, passengers, passengersAvg, arrivals, routes));
            }

            Traffic = new List<AirportTrafficMVVM>();

            IOrderedEnumerable<Airport> passengerDestinations = from a in Airports.GetAllActiveAirports()
                orderby Airport.GetDestinationPassengerStatistics(a) descending
                select a;
            IOrderedEnumerable<Airport> cargoDestinations = from a in Airports.GetAllActiveAirports()
                orderby Airport.GetDestinationCargoStatistics(a) descending
                select a;

            foreach (Airport a in passengerDestinations.Take(20))
            {
                Traffic.Add(
                    new AirportTrafficMVVM(
                        a,
                        Airport.GetDestinationPassengerStatistics(a),
                        AirportTrafficMVVM.TrafficType.Passengers));
            }

            foreach (Airport a in cargoDestinations.Take(20))
            {
                Traffic.Add(
                    new AirportTrafficMVVM(
                        a,
                        Convert.ToInt64(Airport.GetDestinationCargoStatistics(a)),
                        AirportTrafficMVVM.TrafficType.Cargo));
            }

            Flights = new List<DestinationFlightsMVVM>();

            IEnumerable<Route> airportRoutes =
                AirportHelpers.GetAirportRoutes(Airport).Where(r => r.GetAirliners().Count > 0);

            foreach (Route airportRoute in airportRoutes)
            {
                double distance = MathHelpers.GetDistance(airportRoute.Destination1, airportRoute.Destination2);

                Airport destination = airportRoute.Destination1 == Airport
                    ? airportRoute.Destination2
                    : airportRoute.Destination1;
                if (Flights.Exists(f => f.Airline == airportRoute.Airline && f.Airport == destination))
                {
                    DestinationFlightsMVVM flight =
                        Flights.First(f => f.Airline == airportRoute.Airline && f.Airport == destination);

                    flight.Flights += airportRoute.TimeTable.GetEntries(destination).Count;

                    foreach (AirlinerType aircraft in airportRoute.GetAirliners().Select(a => a.Airliner.Type))
                    {
                        if (!flight.Aircrafts.Contains(aircraft))
                        {
                            flight.Aircrafts.Add(aircraft);
                        }
                    }
                }
                else
                {
                    Flights.Add(
                        new DestinationFlightsMVVM(
                            destination,
                            airportRoute.Airline,
                            distance,
                            airportRoute.GetAirliners().Select(a => a.Airliner.Type).ToList(),
                            airportRoute.TimeTable.GetEntries(destination).Count));
                }
            }
            /*
            Dictionary<Airport, int> destinations = new Dictionary<Airport, int>();
            foreach (Route route in AirportHelpers.GetAirportRoutes(this.Airport).FindAll(r => r.getAirliners().Count > 0))
            {
                if (route.Destination1 != this.Airport)
                {
                    if (!destinations.ContainsKey(route.Destination1))
                        destinations.Add(route.Destination1, 0);
                    destinations[route.Destination1] += route.TimeTable.getEntries(route.Destination1).Count;

                }
                if (route.Destination2 != this.Airport)
                {
                    if (!destinations.ContainsKey(route.Destination2))
                        destinations.Add(route.Destination2, 0);
                    destinations[route.Destination2] += route.TimeTable.getEntries(route.Destination2).Count;
                }
            }

            foreach (Airport a in destinations.Keys)
                this.Flights.Add(new DestinationFlightsMVVM(a, destinations[a]));
            */

            Hubs = new ObservableCollection<Hub>();

            foreach (Hub hub in Airport.GetHubs())
            {
                Hubs.Add(hub);
            }

            CanBuildHub = canBuildHub();
            CanMakeCooperation = GameObject.GetInstance().HumanAirline.Airports.Exists(a => a == Airport);

            LocalTime = MathHelpers.ConvertDateTimeToLoalTime(
                GameObject.GetInstance().GameTime,
                Airport.Profile.TimeZone);

            ShowLocalTime = !GameObject.GetInstance().DayRoundEnabled;

            AirlineReputations = new List<AirlineReputationMVVM>();

            IDictionary<Airline, double> airlineScores = new Dictionary<Airline, double>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                airlineScores.Add(airline, Airport.GetAirlineReputation(airline));
            }

            foreach (var score in StatisticsHelpers.GetRatingScale(airlineScores))
            {
                AirlineReputations.Add(new AirlineReputationMVVM(score.Key, (int)score.Value));
            }
        }