public ActionResult Delete(int Item) { // TODO: Move all items under this category to parent category using (var database = new DatabaseEntities()) { var category = database.CategoryById(Item); if (category != null) { database.DeleteObject(category); database.SaveChanges(); } } return RedirectToAction("Index"); }
public ActionResult Add(AddCategoryViewModel viewModel) { if (!ModelState.IsValid) return View(viewModel); var category = new Category { Name = viewModel.Name, Parent = viewModel.Parent }; using (var database = new DatabaseEntities()) { database.AddToCategories(category); database.SaveChanges(); } return RedirectToAction("Index"); }
public ActionResult Rename(int Id, string NewName) { using (var database = new DatabaseEntities()) { var category = database.CategoryById(Id); category.Name = NewName; database.SaveChanges(); } return RedirectToAction("Index"); }