public bool EditValidationCheck(int?menuId, EditMenuMasterViewModel editMenu) { var result = (from menu in _frapperDbContext.MenuMasters.AsNoTracking() where menu.MenuId == menuId select menu).SingleOrDefault(); if (result != null && (editMenu.MenuCategoryId == result.MenuCategoryId && editMenu.RoleId == result.RoleId && editMenu.MenuName == result.MenuName)) { return(true); } else { return(false); } }
public ActionResult Edit(EditMenuMasterViewModel editmenuMaster) { try { if (ModelState.IsValid) { if (_iMenu.EditValidationCheck(editmenuMaster.MenuId, editmenuMaster)) { MenuMaster menuMaster = new MenuMaster() { UserId = Convert.ToInt64(_sessionHandler.UserId), MenuName = editmenuMaster.MenuName, Status = editmenuMaster.Status, ActionMethod = editmenuMaster.ActionMethod, ControllerName = editmenuMaster.ControllerName, MenuId = editmenuMaster.MenuId, CategoryId = editmenuMaster.MenuCategoryId, RoleId = editmenuMaster.RoleId, ModifiedDate = DateTime.Now }; _iMenu.UpdateMenu(menuMaster); TempData["MenuUpdateMessages"] = CommonMessages.MenuUpdateMessages; } else if (_iMenu.CheckMenuNameExists(editmenuMaster.MenuName, editmenuMaster.RoleId, editmenuMaster.MenuCategoryId)) { ModelState.AddModelError("", CommonMessages.MenuNameAlreadyExistsMessages); editmenuMaster.AllActiveRoles = _role.GetAllActiveRoles(); editmenuMaster.ListofMenuCategory = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; return(View(editmenuMaster)); } else { MenuMaster menuMaster = new MenuMaster() { UserId = Convert.ToInt64(_sessionHandler.UserId), MenuName = editmenuMaster.MenuName, Status = editmenuMaster.Status, ActionMethod = editmenuMaster.ActionMethod, ControllerName = editmenuMaster.ControllerName, MenuId = editmenuMaster.MenuId, CategoryId = editmenuMaster.MenuCategoryId, RoleId = editmenuMaster.RoleId, ModifiedDate = DateTime.Now }; _iMenu.UpdateMenu(menuMaster); TempData["MenuUpdateMessages"] = CommonMessages.MenuUpdateMessages; } editmenuMaster.AllActiveRoles = _role.GetAllActiveRoles(); editmenuMaster.ListofMenuCategory = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; return(View(editmenuMaster)); } editmenuMaster.AllActiveRoles = _role.GetAllActiveRoles(); editmenuMaster.ListofMenuCategory = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; return(View(editmenuMaster)); } catch (Exception) { throw; } }
public IActionResult Edit(EditMenuMasterViewModel editmenuMaster) { try { editmenuMaster.ListofRoles = _roleQueries.ListofRoles(); editmenuMaster.ListofMenuCategory = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; if (ModelState.IsValid) { MenuMaster menuMaster = new MenuMaster() { ModifiedBy = Convert.ToInt64(HttpContext.Session.Get <string>(AllSessionKeys.UserId)), MenuName = editmenuMaster.MenuName, Status = editmenuMaster.Status, ActionMethod = editmenuMaster.ActionMethod, ControllerName = editmenuMaster.ControllerName, MenuId = editmenuMaster.MenuId, MenuCategoryId = editmenuMaster.MenuCategoryId, RoleId = editmenuMaster.RoleId, ModifiedOn = DateTime.Now, Area = editmenuMaster.Area }; if (_iMenuMasterQueries.EditValidationCheck(editmenuMaster.MenuId, editmenuMaster)) { _iUnitOfWork.MenuMasterCommand.Update(menuMaster); _iUnitOfWork.Commit(); _notificationService.SuccessNotification("Message", "Menu was updated Successfully!"); return(RedirectToAction("Index", "MenuMaster")); } else if (_iMenuMasterQueries.CheckMenuExists(editmenuMaster.MenuName, editmenuMaster.RoleId, editmenuMaster.MenuCategoryId)) { ModelState.AddModelError("", "Menu Name Already Exists"); editmenuMaster.ListofRoles = _roleQueries.ListofRoles(); editmenuMaster.ListofMenuCategory = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; return(View(editmenuMaster)); } else { _iUnitOfWork.MenuMasterCommand.Update(menuMaster); _iUnitOfWork.Commit(); _notificationService.SuccessNotification("Message", "Menu was updated Successfully!"); return(RedirectToAction("Index", "MenuMaster")); } } return(View(editmenuMaster)); } catch (Exception) { throw; } }