public ActionResult Edit(MenuCategory menuCategory) { if (ModelState.IsValid) { menuRepository.SaveMenuCategory(menuCategory); TempData["message"] = MessageHelper.BuildMessage(EnumSevereLevel.Success, string.Format("{0} has been created!", menuCategory.MenuCategoryName)); return RedirectToAction("List"); } else { //There is something wrong with the data values TempData["message"] = MessageHelper.BuildMessage(EnumSevereLevel.Error, "There is something wrong with the data values, please check!"); return View(menuCategory); } }
public void SaveMenuCategory(MenuCategory menuCategory) { if (menuCategory.MenuCategoryId == 0) { context.MenuCategories.Add(menuCategory); } else { MenuCategory dbEntry = context.MenuCategories.Find(menuCategory.MenuCategoryId); if (dbEntry != null) { dbEntry.MenuCategoryName = menuCategory.MenuCategoryName; dbEntry.Sequence = menuCategory.Sequence; } } context.SaveChanges(); }
public SelectMenuCategoryEditorViewModel(MenuCategory category) { this.MenuCategoryId = category.MenuCategoryId; this.MenuCategoryName = category.MenuCategoryName; }