public ActionResult Edit([Bind(Include = "id,typeId,name,image,detail,price")] Cake cake)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cake).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.typeId = new SelectList(db.Types, "id", "name", cake.typeId);
     return(View(cake));
 }
Пример #2
0
 public ActionResult EditProduct([Bind(Include = "productId, productName, productImage, productPrice, productDescription, createAt")] Product product)
 {
     try
     {
         // TODO: Add update logic here
         if (ModelState.IsValid)
         {
             db.Entry(product).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(product));
     }
 }