public ActionResult Edit(TopMenu topMenu) { if (ModelState.IsValid) { menuRepository.SaveTopMenu(topMenu); TempData["message"] = MessageHelper.BuildMessage(EnumSevereLevel.Success, string.Format("{0} has been created!", topMenu.TopMenuName)); 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(topMenu); } }
public void SaveTopMenu(TopMenu topMenu) { if (topMenu.TopMenuId == 0) { context.TopMenus.Add(topMenu); } else { TopMenu dbEntry = context.TopMenus.Find(topMenu.TopMenuId); if (dbEntry != null) { dbEntry.TopMenuName = topMenu.TopMenuName; dbEntry.PageLink = topMenu.PageLink; dbEntry.Image = topMenu.Image; dbEntry.ToolTip = topMenu.ToolTip; dbEntry.Sequence = topMenu.Sequence; } } context.SaveChanges(); }