private static async Task SeedProducts(ShoppingDBContext context) { if (!context.Products.Any()) { context.AddRange(ProductSeed.PopulateProductList()); await context.SaveChangesAsync().ConfigureAwait(false); { } } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ShoppingDBContext dbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Shopping API")); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); dbContext.Database.EnsureCreated(); }
public static async Task SeedAsync(ShoppingDBContext context) { await SeedProducts(context).ConfigureAwait(false); }
public UnitOfWork(ShoppingDBContext shoppingDBContext) { this._shoppingDBContext = shoppingDBContext; }
public CustomersController(ShoppingDBContext context) { _context = context; }
public ProductsController(ShoppingDBContext context) { _context = context; }
public CategoriesController(ShoppingDBContext _context, IMapper _mapper) { this.context = _context; this.mapper = _mapper; }
public OrderRepository(ShoppingDBContext context) : base(context) { _shoppingDBContext = context; }
public ShoppingCartController(ShoppingDBContext context) { _context = context; }
public SalesController(ShoppingDBContext context) { _context = context; }
public ShoppingRepository(ShoppingDBContext dbContext) { _dbContext = dbContext; }
public ProductService(ShoppingDBContext context, IStorageService storageService) { _context = context; _storageService = storageService; }
public SqlRepository(ShoppingDBContext context) { this._context = context; }
public PublicProductService(ShoppingDBContext context) { _context = context; }
public ItemService(ShoppingDBContext context) { _context = context; }
public GenericRepository(ShoppingDBContext apiContext) { context = apiContext; }
public CustomerController(ShoppingDBContext _context, IMapper _mapper) { this.context = _context; this.mapper = _mapper; }