public ActionResult Edit(ProductCategoryManageEditViewModel model) { if (ModelState.IsValid) { var productCategory = new ProductCategory { Id = model.Id, Name = model.Name, Description = model.Description, UrlSlug = model.UrlSlug }; db.Entry(productCategory).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(model); }
// GET: ProductCategoryManage/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } ProductCategory productCategory = db.ProductCategories.Find(id); if (productCategory == null) { return HttpNotFound(); } var vm =new ProductCategoryManageEditViewModel{ Id=productCategory.Id, Name=productCategory.Name, Description=productCategory.Description, UrlSlug=productCategory.UrlSlug }; return View(vm); }