public static void Initialize(AutoShopDbContext dbContext) { _ = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); if (!dbContext.Categories.Any()) { dbContext.Categories.AddRange(CategoryConsts.Categories.Values); dbContext.SaveChanges(); } if (!dbContext.Cars.Any()) { var carsRepo = new MockCarRepository(); dbContext.Cars.AddRange(carsRepo.GetAll()); dbContext.SaveChanges(); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app) { app.UseDeveloperExceptionPage(); app.UseStatusCodePages(); app.UseStaticFiles(); app.UseSession(); app.UseMvc(routes => { routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{Id?}"); routes.MapRoute(name: "categoryFilter", template: "Cars/{action}/{category?}", defaults: new { Controller = "Car", action = "List" }); }); using (var scope = app.ApplicationServices.CreateScope()) { AutoShopDbContext context = scope.ServiceProvider.GetRequiredService <AutoShopDbContext>(); DbObjects.Initial(context); } }
public CategoryRepository(AutoShopDbContext autoShopDbContext) { this.autoShopDbContext = autoShopDbContext; }
public OrderRepository(AutoShopDbContext carsDbContext) { _autoShopDb = carsDbContext ?? throw new ArgumentNullException(nameof(carsDbContext)); }
public OrderRepository(AutoShopDbContext autoShopDbContext, AutoShopCart autoShopCart) { this.autoShopDbContext = autoShopDbContext; this.autoShopCart = autoShopCart; }
public CustomerCartItemRepository(AutoShopDbContext carsDbContext) { _autoShopDb = carsDbContext ?? throw new ArgumentNullException(nameof(carsDbContext)); }
public AutoShopCart(AutoShopDbContext autoShopDbContext) { this.autoShopDbContext = autoShopDbContext; }
public AutoShopCartRepository(AutoShopDbContext autoShopDbContext) { this.autoShopDbContext = autoShopDbContext; }