public ActionResult Create(SubMenuMasterCreate subMenuMasterVm) { try { if (ModelState.IsValid) { SubMenuMaster subMenuMaster = new SubMenuMaster() { SubMenuId = 0, RoleId = subMenuMasterVm.RoleID, CategoryId = subMenuMasterVm.MenuCategoryId, MenuId = subMenuMasterVm.MenuId, Status = subMenuMasterVm.Status, ActionMethod = subMenuMasterVm.ActionMethod, ControllerName = subMenuMasterVm.ControllerName, SubMenuName = subMenuMasterVm.SubMenuName, CreateDate = DateTime.Now }; subMenuMaster.UserId = Convert.ToInt32(_sessionHandler.UserId); _subMenu.AddSubMenu(subMenuMaster); return(RedirectToAction("Index")); } subMenuMasterVm.MenuList = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; subMenuMasterVm.ListofMenuCategory = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; subMenuMasterVm.ListofRoles = _role.GetAllActiveRoles(); return(View(subMenuMasterVm)); } catch (Exception) { throw; } }
public void DeleteSubMenu(int?subMenuId) { try { SubMenuMaster subMenuMaster = _context.SubMenuMasters.Find(subMenuId); if (subMenuMaster != null) { _context.SubMenuMasters.Remove(subMenuMaster); } _context.SaveChanges(); } catch (Exception) { throw; } }
public int DeleteSubMenu(int?subMenuId) { try { SubMenuMaster subMenuMaster = _context.SubMenuMasters.Find(subMenuId); if (subMenuMaster != null) { _context.Entry(subMenuMaster).State = EntityState.Deleted; } return(_context.SaveChanges()); } catch (Exception) { throw; } }
public int?AddSubMenu(SubMenuMaster subMenuMaster) { try { int?result = -1; if (subMenuMaster != null) { subMenuMaster.CreateDate = DateTime.Now; _context.SubMenuMasters.Add(subMenuMaster); _context.SaveChanges(); result = subMenuMaster.MenuId; } return(result); } catch (Exception) { throw; } }
public int?UpdateSubMenu(SubMenuMaster subMenuMaster) { try { int?result = -1; if (subMenuMaster != null) { subMenuMaster.CreateDate = DateTime.Now; _context.Entry(subMenuMaster).State = EntityState.Modified; _context.SaveChanges(); result = subMenuMaster.SubMenuId; } return(result); } catch (Exception) { throw; } }
// GET: SubMenuMaster/Delete/5 public ActionResult Delete(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SubMenuMaster subMenuMaster = _subMenu.GetSubMenuById(id); if (subMenuMaster == null) { return(HttpNotFound()); } return(View(subMenuMaster)); } catch (Exception) { throw; } }
public IActionResult Edit(EditSubMenuMasterViewModel subMenuMasterVm) { try { subMenuMasterVm.ListofRoles = _roleQueries.ListofRoles(); subMenuMasterVm.ListofMenuCategory = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; subMenuMasterVm.ListofMenus = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; if (ModelState.IsValid) { if (_subMenuMasterQueries.EditValidationCheck(subMenuMasterVm.SubMenuId, subMenuMasterVm)) { SubMenuMaster subMenuMaster = new SubMenuMaster() { SubMenuId = subMenuMasterVm.SubMenuId, RoleId = subMenuMasterVm.RoleId, MenuCategoryId = subMenuMasterVm.MenuCategoryId, MenuId = subMenuMasterVm.MenuId, Status = subMenuMasterVm.Status, ActionMethod = subMenuMasterVm.ActionMethod, Area = subMenuMasterVm.Area, ControllerName = subMenuMasterVm.ControllerName, SubMenuName = subMenuMasterVm.SubMenuName, CreatedOn = DateTime.Now, }; subMenuMaster.CreatedBy = Convert.ToInt64(HttpContext.Session.Get <string>(AllSessionKeys.UserId)); _unitOfWorkEntityFramework.SubMenuMasterCommand.Update(subMenuMaster); _unitOfWorkEntityFramework.Commit(); _notificationService.SuccessNotification("Message", "SubMenu was Updated Successfully!"); return(RedirectToAction("Index", "SubMenuMaster")); } else if (_subMenuMasterQueries.CheckSubMenuNameExists(subMenuMasterVm.SubMenuName, subMenuMasterVm.MenuId, subMenuMasterVm.RoleId, subMenuMasterVm.MenuCategoryId)) { ModelState.AddModelError("", "SubMenu Already Exists"); return(View(subMenuMasterVm)); } else { SubMenuMaster subMenuMaster = new SubMenuMaster() { SubMenuId = subMenuMasterVm.SubMenuId, RoleId = subMenuMasterVm.RoleId, MenuCategoryId = subMenuMasterVm.MenuCategoryId, MenuId = subMenuMasterVm.MenuId, Status = subMenuMasterVm.Status, Area = subMenuMasterVm.Area, ControllerName = subMenuMasterVm.ControllerName, ActionMethod = subMenuMasterVm.ActionMethod, SubMenuName = subMenuMasterVm.SubMenuName, CreatedOn = DateTime.Now }; subMenuMaster.CreatedBy = Convert.ToInt64(HttpContext.Session.Get <string>(AllSessionKeys.UserId)); _unitOfWorkEntityFramework.SubMenuMasterCommand.Update(subMenuMaster); _unitOfWorkEntityFramework.Commit(); _notificationService.SuccessNotification("Message", "SubMenu was Updated Successfully!"); } return(RedirectToAction("Index", "SubMenuMaster")); } return(View(subMenuMasterVm)); } catch (Exception) { throw; } }
public ActionResult Edit(EditSubMenuMaster subMenuMasterVm) { try { if (ModelState.IsValid) { if (_subMenu.EditValidationCheck(subMenuMasterVm.SubMenuId, subMenuMasterVm)) { SubMenuMaster subMenuMaster = new SubMenuMaster() { SubMenuId = subMenuMasterVm.SubMenuId, RoleId = subMenuMasterVm.RoleID, CategoryId = subMenuMasterVm.MenuCategoryId, MenuId = subMenuMasterVm.MenuId, Status = subMenuMasterVm.Status, ActionMethod = subMenuMasterVm.ActionMethod, ControllerName = subMenuMasterVm.ControllerName, SubMenuName = subMenuMasterVm.SubMenuName, CreateDate = DateTime.Now }; subMenuMaster.UserId = Convert.ToInt32(_sessionHandler.UserId); _subMenu.UpdateSubMenu(subMenuMaster); TempData["MenuUpdateMessages"] = CommonMessages.MenuUpdateMessages; } else if (_subMenu.CheckSubMenuNameExists(subMenuMasterVm.SubMenuName, subMenuMasterVm.MenuId, subMenuMasterVm.RoleID, subMenuMasterVm.MenuCategoryId)) { ModelState.AddModelError("", CommonMessages.MenuNameAlreadyExistsMessages); subMenuMasterVm.ListofRoles = _role.GetAllActiveRoles(); subMenuMasterVm.ListofMenuCategory = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; subMenuMasterVm.MenuList = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; return(View(subMenuMasterVm)); } else { SubMenuMaster subMenuMaster = new SubMenuMaster() { SubMenuId = subMenuMasterVm.SubMenuId, RoleId = subMenuMasterVm.RoleID, CategoryId = subMenuMasterVm.MenuCategoryId, MenuId = subMenuMasterVm.MenuId, Status = subMenuMasterVm.Status, ActionMethod = subMenuMasterVm.ActionMethod, ControllerName = subMenuMasterVm.ControllerName, SubMenuName = subMenuMasterVm.SubMenuName, CreateDate = DateTime.Now }; subMenuMaster.UserId = Convert.ToInt32(_sessionHandler.UserId); _subMenu.UpdateSubMenu(subMenuMaster); TempData["MenuUpdateMessages"] = CommonMessages.MenuUpdateMessages; } return(RedirectToAction("Index")); } subMenuMasterVm.ListofRoles = _role.GetAllActiveRoles(); subMenuMasterVm.ListofMenuCategory = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; subMenuMasterVm.MenuList = new List <SelectListItem>() { new SelectListItem() { Value = "", Text = "-----Select-----" } }; return(View(subMenuMasterVm)); } catch (Exception) { throw; } }
public void Update(SubMenuMaster subMenuMaster) { _frapperDbContext.Entry(subMenuMaster).State = EntityState.Modified; }
public void Delete(SubMenuMaster subMenuMaster) { _frapperDbContext.Entry(subMenuMaster).State = EntityState.Deleted; }
public void Add(SubMenuMaster subMenuMaster) { _frapperDbContext.SubMenuMasters.Add(subMenuMaster); }