示例#1
0
        // 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();
        }
示例#2
0
        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();
        }
示例#3
0
 public UserController(NetshopDbContext context)
 {
     _context = context;
 }
 public CategoryController(NetshopDbContext context)
 {
     _context = context;
 }
示例#5
0
 // Constructor
 public CartController(NetshopDbContext context)
 {
     _context = context;
 }
 public ProductController(NetshopDbContext context)
 {
     _context = context;
 }