public void CreateCategory(ProductCategory category) { if (category != null) { Context.ProductCategories.Add(category); } }
public void UpdateCategory(ProductCategory category) { if (category != null) { Context.Entry(category).State = EntityState.Modified; } }
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); }