public static void Initialize(MvcAppContext context) { context.Database.EnsureCreated(); // Look for any students. if (context.Deliveries.Any()) { return; // DB has been seeded } var deliveries = new List <Delivery>(); var tuesdays = GetDatesByDayOfWeek(2018, DayOfWeek.Tuesday); var thursdays = GetDatesByDayOfWeek(2018, DayOfWeek.Thursday); foreach (var day in tuesdays) { deliveries.Add(new Delivery { Date = day, Status = FacturationWebSite.Models.Enum.DeliveryStatus.Pending }); } foreach (var day in thursdays) { deliveries.Add(new Delivery { Date = day, Status = FacturationWebSite.Models.Enum.DeliveryStatus.Pending }); } foreach (Delivery d in deliveries) { context.Deliveries.Add(d); } context.SaveChanges(); }
public static void Main(string[] args) { IWebHost host = CreateWebHostBuilder(args).Build(); using (IServiceScope scope = host.Services.CreateScope()) { IServiceProvider services = scope.ServiceProvider; try { MvcAppContext context = services.GetRequiredService <MvcAppContext>(); context.Database.Migrate(); SeedData.InitializeData(services); } catch (Exception ex) { ILogger <Program> logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "There was an error seeding the database"); throw; } } host.Run(); }
public EmployeesController(MvcAppContext mvcAppContext) { this._context = mvcAppContext; }
public HomeController(MvcAppContext context) { _context = context; }
public InvoiceLineController(MvcAppContext context) { _context = context; }
public BarcodeController(MvcAppContext context) { _context = context; }
public MusicController(MvcAppContext context) { _context = context; }
public PeopleController(MvcAppContext context) { _context = context; }
public DepartmentsController(MvcAppContext mvcAppContext) { _context = mvcAppContext; }
public CustomerPriceController(MvcAppContext context) { _context = context; }
public DeliveryController(MvcAppContext context) { _context = context; }
public MoviesController(MvcAppContext context) { _context = context; }
public ProductController(MvcAppContext context) { _context = context; }