public bool SaveMenuItem(AddProfileMenu model) { if (this.Context.ProfileMenus.Any( m => m.System == model.System && m.Role == model.Role && m.Description == model.Description)) { return(false); } var menu = new ProfileMenu { System = model.System, Role = model.Role, Description = model.Description }; this.Context.ProfileMenus.Add(menu); this.Context.SaveChanges(); return(true); }
public ActionResult Add(AddProfileMenu model) { if (!ModelState.IsValid || model.System == string.Empty) { TempData.Add("NotChoosenSystem", "Задължително трябва да въведете Име на услуга!"); return(View(model)); } if (!ModelState.IsValid || model.Role == string.Empty) { TempData.Add("NotChoosenRole", "Задължително трябва да въведете стойност в поле роля/права/достъп!"); return(View(model)); } var menu = service.SaveMenuItem(model); if (!menu) { TempData.Add("DuplicateRow", "Такъв достъп вече съществува."); return(View(model)); } return(RedirectToAction("AddInfo", "Menu", model)); }
// GET public ActionResult AddInfo(AddProfileMenu model) { return(View(model)); }