public static void Seed(this ModelBuilder builder) { builder.Entity(typeof(City)).HasData(new City[] { new City { Id = 1, Name = "Londres" }, new City { Id = 2, Name = "Paris" }, new City { Id = 3, Name = "Berlin" }, new City { Id = 4, Name = "Bruxelles" }, new City { Id = 5, Name = "Lisbonne" }, new City { Id = 6, Name = "Madrid" }, new City { Id = 7, Name = "Rome" }, }); builder.Entity(typeof(Fly)).HasData(new Fly[] { new Fly { Id = 1, Number = StringUtilsHelper.getNumber(), Departure = 1, Arrival = 2, Time = DateTime.Now, Price = 280, Seat = 30, Reduction = false }, }); }
public async Task <IActionResult> Create(Fly flyModel) { flyModel.Number = StringUtilsHelper.getNumber(); if (ModelState.IsValid) { await _flyService.Add(flyModel); return(RedirectToAction(nameof(Index))); } var cities = await _cityService.All(); ViewBag.Departure = new SelectList(cities, "Id", "Name"); ViewBag.Arrival = new SelectList(cities, "Id", "Name"); return(View(flyModel)); }