Example #1
0
        public ActionResult Show(string flightNumber, DateTime departureTime, DateTime arrivalTime, string airline, string status, int departureCity, int arrivalCity)
        {
            Flight newFlight = new Flight(flightNumber, departureTime, arrivalTime, airline, status);

            newFlight.Save();
            newFlight.AddFlight(departureCity, arrivalCity);
            List <Flight> allFlights = Flight.GetAll();

            return(View("Index", allFlights));
        }
Example #2
0
        private void ParseFlights(XElement xFlights)
        {
            var flights = xFlights.Elements("flight").Select(f =>
                                                             new Flight
            {
                Distance      = (int.Parse(f.Element("distance").Value)),
                Id            = f.Element("id").Value.ToString(),
                TimeIntervale = (int.Parse(f.Element("time").Value)),
                Origin        = _cities.SingleOrDefault(c => c.Id == f.Element("origin").Value),
                Destination   = _cities.SingleOrDefault(c => c.Id == f.Element("destination").Value),
                Airline       = _airlines.SingleOrDefault(a => a.Id == int.Parse(f.Element("airlineId").Value))
            }).ToList();

            foreach (Flight f in flights)
            {
                Flight.AddFlight(f);

                if (f.Airline != null)
                {
                    var airline = _airlines.Single(a => a.Id == f.Airline.Id);
                    airline.AddFlight(f);
                }
            }
        }