Esempio n. 1
0
 public ActionResult Edit([Bind(Include = "Id,Name")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Esempio n. 2
0
 public ActionResult Edit([Bind(Include = "Id,Name,CategoryId")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", new { id = product.CategoryId }));
     }
     ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", product.CategoryId);
     return(View(product));
 }