public ActionResult AddCategory(Category category) { if (ModelState.IsValid) { this.Data.Categories.Add(new Category { Name = category.Name }); this.Data.SaveChanges(); return this.RedirectToAction("Index", "Home"); } return this.View(); }
public ActionResult EditCategory(int id, Category category) { var currentCategory = this.Data.Categories.Find(id); if (currentCategory == null) { return this.HttpNotFound(); } if (ModelState.IsValid) { currentCategory.Name = category.Name; this.Data.SaveChanges(); //return RedirectToAction("Index", "Home"); } return this.View(); }