public ActionResult Create(ProductCategoryManageCreateViewModel model) { if (ModelState.IsValid) { var productCategory = new ProductCategory { Name = model.Name, Description = model.Description, UrlSlug = model.UrlSlug }; db.ProductCategories.Add(productCategory); db.SaveChanges(); return RedirectToAction("Index"); } return View(model); }
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); }