コード例 #1
0
        public static void Seed(ProductDatabaseContext _context)
        {
            product temp = new product("Asus N550JK", 20, 7799.90, "Asus N550JK laptop");

            _context.product.Add(temp);
            _context.SaveChanges();
            temp = new product("IPhone S12", 56, 10999.90, "IPhone S12 Smartphone");
            _context.product.Add(temp);
            _context.SaveChanges();
            temp = new product("Logitech K360", 48, 299.90, "Logitech wireless keyboard");
            _context.product.Add(temp);
            _context.SaveChanges();
            temp = new product("Logitech A67", 20, 7799.90, "Logitech 3+1 Sound System");
            _context.product.Add(temp);
            _context.SaveChanges();
            temp = new product("Samsung A50", 85, 7799.90, "Samsung A50 Smartphone");
            _context.product.Add(temp);
            _context.SaveChanges();
        }
コード例 #2
0
        public ActionResult resetSeed()
        {
            // clear products
            _context.product.RemoveRange(_context.product.OrderBy(c => c.productName).ToList());
            // add again
            product temp = new product("Asus N550JK", 20, 7799.90, "Asus N550JK laptop");

            _context.product.Add(temp);
            _context.SaveChanges();
            temp = new product("IPhone S12", 56, 10999.90, "IPhone S12 Smartphone");
            _context.product.Add(temp);
            _context.SaveChanges();
            temp = new product("Logitech K360", 48, 299.90, "Logitech wireless keyboard");
            _context.product.Add(temp);
            _context.SaveChanges();
            temp = new product("Logitech A67", 20, 7799.90, "Logitech 3+1 Sound System");
            _context.product.Add(temp);
            _context.SaveChanges();
            temp = new product("Samsung A50", 85, 7799.90, "Samsung A50 Smartphone");
            _context.product.Add(temp);
            _context.SaveChanges();
            return(Ok());
        }
コード例 #3
0
 public void addProduct(product newProduct)
 {
     newProduct.productRegisterDate = DateTime.Now;
     _context.product.Add(newProduct);
     _context.SaveChanges();
 }