public ActionResult Create() { var model = new CategoryViewModel { Categories = ProductManager.GetCategoriesSelectList() }; return View(model); }
public ActionResult Create(CategoryViewModel model) { if (ModelState.IsValid) { var category = new ProductCategory { Name = model.Name, NameShort = model.NameShort, ParentId = model.ParentId }; ProductManager.CreateCategory(category); ProductManager.Save(); return RedirectToAction("Index"); } return View(model); }
public ActionResult Update(Guid? id) { if (id.HasValue) { var entity = ProductManager.FindCategoryById(id.Value); var model = new CategoryViewModel { Id = entity.Id, Name = entity.Name, NameShort = entity.NameShort, ParentId = entity.ParentId, Categories = ProductManager.GetCategoriesSelectList() }; return View("Update", model); } return RedirectToAction("Index"); }