示例#1
0
        public ActionResult Create([Bind(Include = "Id,Name,Price,Quantity,Description,Image,CategoryId,CreatedDate,ModifiedDate,Deleted,TabIndex,PromotionId")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId  = new SelectList(db.Categories, "Id", "Name", product.CategoryId);
            ViewBag.PromotionId = new SelectList(db.Promotions, "Id", "Name", product.PromotionId);
            return(View(product));
        }
示例#2
0
 public void Register(User user)
 {
     db.Users.Add(user);
     db.SaveChanges();
 }
示例#3
0
 public void CreateProduct(Product product)
 {
     db.Products.Add(product);
     db.SaveChanges();
 }