public ActionResult Create(MenuMasterViewModel menuvm) { try { if (ModelState.IsValid) { if (_iMenu.CheckMenuNameExists(menuvm.MenuName, menuvm.RoleId, menuvm.MenuCategoryId)) { ModelState.AddModelError("", CommonMessages.MenuNameAlreadyExistsMessages); menuvm.AllActiveRoles = _role.GetAllActiveRoles(); menuvm.ListofMenuCategory = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; return(View(menuvm)); } MenuMaster menuMaster = new MenuMaster() { UserId = Convert.ToInt64(_sessionHandler.UserId), MenuName = menuvm.MenuName, Status = menuvm.Status, ActionMethod = menuvm.ActionMethod, ControllerName = menuvm.ControllerName, MenuId = 0, CategoryId = menuvm.MenuCategoryId, RoleId = menuvm.RoleId, CreateDate = DateTime.Now }; _iMenu.AddMenu(menuMaster); TempData["MenuSuccessMessages"] = CommonMessages.MenuSuccessMessages; return(RedirectToAction("Create")); } menuvm.AllActiveRoles = _role.GetAllActiveRoles(); menuvm.ListofMenuCategory = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; return(View(menuvm)); } catch (Exception) { throw; } }
public JsonResult CheckMenuName(string menuName) { try { if (!string.IsNullOrEmpty(menuName)) { var result = _iMenu.CheckMenuNameExists(menuName); return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json("", JsonRequestBehavior.AllowGet)); } catch (Exception) { throw; } }