private static async Task SeedProducts(ShoppingDBContext context)
        {
            if (!context.Products.Any())
            {
                context.AddRange(ProductSeed.PopulateProductList());
                await context.SaveChangesAsync().ConfigureAwait(false);

                {
                }
            }
        }
Example #2
0
        // 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;
 }
Example #9
0
 public ShoppingCartController(ShoppingDBContext context)
 {
     _context = context;
 }
Example #10
0
 public SalesController(ShoppingDBContext context)
 {
     _context = context;
 }
 public ShoppingRepository(ShoppingDBContext dbContext)
 {
     _dbContext = dbContext;
 }
Example #12
0
 public ProductService(ShoppingDBContext context, IStorageService storageService)
 {
     _context        = context;
     _storageService = storageService;
 }
Example #13
0
 public SqlRepository(ShoppingDBContext context)
 {
     this._context = context;
 }
 public PublicProductService(ShoppingDBContext context)
 {
     _context = context;
 }
Example #15
0
 public ItemService(ShoppingDBContext context)
 {
     _context = context;
 }
Example #16
0
 public GenericRepository(ShoppingDBContext apiContext)
 {
     context = apiContext;
 }
 public CustomerController(ShoppingDBContext _context, IMapper _mapper)
 {
     this.context = _context;
     this.mapper  = _mapper;
 }