public ActionResult SalesReport2() { if (MenuRestriction.CheckUserMenuAuth(User.Identity.GetUserId(), HttpContext) == false) { return(RedirectToAction("NotAuthorized", "Home")); } return(View()); }
private void InsertMenuRestrictions(string privilegeId, string menuId, bool isChecked) { DIPO_INVESTAMAEntities db = new DIPO_INVESTAMAEntities(); MenuRestriction menuResctriction = new MenuRestriction(); menuResctriction.RestrictionId = Guid.NewGuid().ToString(); menuResctriction.RoleId = privilegeId; menuResctriction.MenuId = menuId; menuResctriction.IsRead = isChecked; menuResctriction.CreatedAt = DateTime.Now; menuResctriction.CreatedBy = SessionManager.userId(); db.MenuRestrictions.Add(menuResctriction); db.SaveChanges(); }
public ActionResult Edit(PrivilegeViewModels Privilege) { if (Privilege.Parent.RoleName == null) { TempData["Error"] = "Name :" + Privilege.Parent.RoleName + " not exist!"; } //check data in database if already exist skip var CheckData = _db.Roles.Where(x => x.RoleName == Privilege.Parent.RoleName && x.RoleId != Privilege.Parent.RoleId).ToList(); if (CheckData.Count() == 0) { if (ModelState.IsValid) { MenuRestrictionsBusinessLogic.getInstance().UpdateRole(Privilege.Parent.RoleId, Privilege.Parent.RoleName); var dt = (from c in _db.MenuRestrictions where c.RoleId == Privilege.Parent.RoleId select c).ToList(); foreach (var item in dt) { MenuRestriction menuRestriction = new MenuRestriction(); menuRestriction.RestrictionId = item.RestrictionId; menuRestriction.MenuId = item.RestrictionId; menuRestriction.RoleId = item.RoleId; menuRestriction.IsRead = item.IsRead; MenuRestrictionsBusinessLogic.getInstance().UpdateMenuRestriction(menuRestriction); } MenuRestrictionsBusinessLogic.getInstance().SaveMenu(Privilege.Menu, Privilege.Parent.RoleId); TempData["Success"] = "Success Editing Data for " + Privilege.Parent.RoleName; return(RedirectToAction("Index")); } } else { TempData["Error"] = "Name :" + Privilege.Parent.RoleName + " already exist!"; } return(View(Privilege)); }
public void UpdateMenuRestriction(MenuRestriction menuRestriction) { _db.sp_PrivilegeUpdate(menuRestriction.RestrictionId, SessionManager.userId(), menuRestriction.RoleId, menuRestriction.MenuId, menuRestriction.IsRead); }