static void CreateData() { using (FlugDbContext ctx = new FlugDbContext()) { ctx.Database.EnsureDeleted(); ctx.Database.EnsureCreated(); var f1 = new Flight { From = "Vienna", To = "London", Date = DateTime.Now }; var b1 = new Booking { Price = 300 }; f1.Bookings.Add(b1); ctx.Flights.Add(f1); ctx.SaveChanges(); #region addFurtherData var f2 = new Flight { From = "Vienna", To = "London", Date = DateTime.Now.AddHours(1) }; var f3 = new Flight { From = "Graz", To = "Hamburg", Date = DateTime.Now.AddHours(2) }; var f4 = new Flight { From = "Hamburg", To = "Graz", Date = DateTime.Now.AddHours(3) }; var f5 = new Flight { From = "Vienna", To = "London", Date = DateTime.Now.AddHours(4) }; var f6 = new Flight { From = "Graz", To = "Hamburg", Date = DateTime.Now.AddHours(5) }; var f7 = new Flight { From = "Vienna", To = "London", Date = DateTime.Now.AddHours(6) }; ctx.Flights.AddRange(f2, f3, f4, f5, f6); ctx.Flights.Add(f7); ctx.SaveChanges(); #endregion } }
static bool CheckRoute(Flight f, string route) { return (f.From + "-" + f.To) == route; }