internal void AddTrip(String from, String to, DateTime takeof, DateTime arrival, int planeId)
 {
     if (arrival > takeof && Airplanes.Find(planeId) != null)
     {
         Trips.Add(new Trip {
             From = from, To = to, Takeof = takeof, Arrival = arrival, AirplaneId = planeId
         });
     }
     this.SaveChanges();
 }
        internal void AddTrip()
        {
            try
            {
                Console.WriteLine("Enter home airport");
                String from = Console.ReadLine();
                Console.WriteLine("Enter airport of destination");
                String to = Console.ReadLine();

                Console.WriteLine("Chose company Id from the list");
                Console.WriteLine($@"                  id     company");
                foreach (var x in this.Companies)
                {
                    Console.WriteLine($@"                  {x.CompanyId}     {x.Name}");
                }
                Console.WriteLine("Enter company id, from the list above\n");
                String id        = Console.ReadLine();
                int    companyId = int.Parse(id);

                Console.WriteLine("Chose airplane Id from the list");
                Console.WriteLine($@"                  id     Airplane");
                foreach (var x in this.Airplanes)
                {
                    if (x.CompanyId == companyId)
                    {
                        Console.WriteLine($@"                  {x.AirplaneId}     {x.Manufacturer}  {x.Model}");
                    }
                }
                Console.WriteLine("Enter airplane id, from the list above\n");
                String     aPid    = Console.ReadLine();
                int        planeId = int.Parse(aPid);
                List <int> planes  = new List <int>();
                foreach (var x in Airplanes)
                {
                    if (x.CompanyId == companyId)
                    {
                        planes.Add(x.AirplaneId);
                    }
                }

                if (!planes.Contains(planeId))
                {
                    throw new Exception();
                }


                Console.WriteLine("Enter takeof time in format yyyy-MM-dd HH:mm");
                String   temp1  = Console.ReadLine();
                DateTime takeof = DateTime.ParseExact(temp1, "yyyy-MM-dd HH:mm", null);

                Console.WriteLine("Enter arrival time in format yyyy-MM-dd HH:mm");
                temp1 = Console.ReadLine();
                DateTime arrival = DateTime.ParseExact(temp1, "yyyy-MM-dd HH:mm", null);


                if (arrival > takeof && Airplanes.Find(planeId) != null)
                {
                    AddTrip(from, to, takeof, arrival, planeId);
                }
                else
                {
                    Console.WriteLine("Data is not correct");
                }
                this.SaveChanges();
                MainMenu();
            }
            catch (Exception e)
            {
                Console.WriteLine("Data input is not correct");
            }
        }