// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, NetshopDbContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } addMockData(context); app.UseMvc(); }
private static void addMockData(NetshopDbContext context) { // Mock users context.Users.Add(new User { Login = "******", Password = "******", Firstname = "Marc", Lastname = "Picaud", Admin = true, Token = "admin" }); context.Users.Add(new User { Login = "******", Password = "******", Firstname = "Jean", Lastname = "Dupont", Admin = false, Token = "client" }); // Mock categories context.Categories.Add(new Category { Name = "category 1" }); context.Categories.Add(new Category { Name = "category 2" }); // Mock products context.Products.Add(new Product { Name = "product 1", Price = 4.2 }); context.Products.Add(new Product { Name = "product 2", Price = 8.4 }); // Mock carts context.Carts.Add(new Cart { UserId = 1, ProductIds = "1,2" }); context.Carts.Add(new Cart { UserId = 2, ProductIds = "1" }); // Mock orders // TODO context.SaveChanges(); }
public UserController(NetshopDbContext context) { _context = context; }
public CategoryController(NetshopDbContext context) { _context = context; }
// Constructor public CartController(NetshopDbContext context) { _context = context; }
public ProductController(NetshopDbContext context) { _context = context; }