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)); }
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)); }