Ejemplo n.º 1
0
        public void DisplayFlights()
        {
            FlightsService flightsService = new FlightsService();
            List <string>  flights        = flightsService.GetFlightSchedule();

            Console.WriteLine("Flights Information: ");
            foreach (string flight in flights)
            {
                Console.WriteLine(flight);
            }
        }
Ejemplo n.º 2
0
        private List <Order> DistributeOrdersToFlights(List <Order> orders)
        {
            FlightsService flightsService = new FlightsService();
            List <Flight>  flights        = flightsService.GetFlights();

            foreach (Order order in orders)
            {
                switch (order.Destination)
                {
                case toronto:
                    Flight torontoFlightOne = flights.FirstOrDefault(f => f.Arrival == toronto && f.Day == 1);
                    Flight torontoFlightTwo = flights.FirstOrDefault(f => f.Arrival == toronto && f.Day == 2);

                    if (torontoFlightOne != null && torontoFlightOne.AddOrder(order))
                    {
                        PopulateOrder(order, torontoFlightOne);
                    }
                    else if (torontoFlightTwo != null && torontoFlightTwo.AddOrder(order))
                    {
                        PopulateOrder(order, torontoFlightTwo);
                    }
                    else
                    {
                        order.FlightNumber = noSchedule;
                    }
                    break;

                case calgory:
                    Flight calgoryFlightOne = flights.FirstOrDefault(f => f.Arrival == calgory && f.Day == 1);
                    Flight calgoryFlightTwo = flights.FirstOrDefault(f => f.Arrival == calgory && f.Day == 2);

                    if (calgoryFlightOne != null && calgoryFlightOne.AddOrder(order))
                    {
                        PopulateOrder(order, calgoryFlightOne);
                    }
                    else if (calgoryFlightTwo != null && calgoryFlightTwo.AddOrder(order))
                    {
                        PopulateOrder(order, calgoryFlightTwo);
                    }
                    else
                    {
                        order.FlightNumber = noSchedule;
                    }
                    break;

                case vancouver:
                    Flight vancouverFlightOne = flights.FirstOrDefault(f => f.Arrival == vancouver && f.Day == 1);
                    Flight vancouverFlightTwo = flights.FirstOrDefault(f => f.Arrival == vancouver && f.Day == 2);

                    if (vancouverFlightOne != null && vancouverFlightOne.AddOrder(order))
                    {
                        PopulateOrder(order, vancouverFlightOne);
                    }
                    else if (vancouverFlightTwo != null && vancouverFlightTwo.AddOrder(order))
                    {
                        PopulateOrder(order, vancouverFlightTwo);
                    }
                    else
                    {
                        order.FlightNumber = noSchedule;
                    }
                    break;

                default:
                    break;
                }
            }
            return(orders);
        }