// GET: UserAccess public ActionResult Index() { // UserAccessRepository objUserAccessRepository = new UserAccessRepository(); List <UserAccessViewModel> objEntityList = objUserAccessRepository.Select(UserAccessFlags.SelectAll.GetHashCode(), new UserAccessViewModel() { }); if (objEntityList.Count == 0) { this.Flash("info", "No User Accesss"); } return(View(objEntityList)); }
public ActionResult Edit(int id) { UserAccessRepository objUserAccessRepository = new UserAccessRepository(); var objEntity = new UserAccessViewModel(); objEntity = objUserAccessRepository.Select(RoleFlags.SelectByID.GetHashCode(), new UserAccessViewModel() { UserAccessId = (Int16)id }).FirstOrDefault(); if (objEntity == null) { this.Flash("Error", "Failed to edit Role details"); return(RedirectToAction("Index")); } return(View(objEntity)); }
public static bool CheckRoleUserAccess(ActionUserAccessEnum objActionUserAccess) { bool isVisible = false; string objController = HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString(); string objAction = HttpContext.Current.Request.RequestContext.RouteData.Values["Action"].ToString(); Int32 UserId = SessionWrapper.UserAccount.UserId; Int16 RoleId = SessionWrapper.UserAccount.RoleId; //Admin only case if (SessionWrapper.UserAccount.RoleId == RoleUserDefinedEnum.Admin.GetHashCode()) { isVisible = true; return(isVisible); } var objUserAccessRepository = new UserAccessRepository(); var objUserAccessViewModel = objUserAccessRepository.Select(UserAccessFlags.SelectPermissionByUrlRoleId.GetHashCode(), RoleId, new UserAccessViewModel() { Url = objController }).FirstOrDefault(); if (objUserAccessViewModel != null) { switch (objActionUserAccess) { case ActionUserAccessEnum.Default: break; case ActionUserAccessEnum.Index: { if (objUserAccessViewModel.ViewPermission == true) { isVisible = true; } break; } case ActionUserAccessEnum.Details: { if (objUserAccessViewModel.ViewPermission == true) { isVisible = true; } break; } case ActionUserAccessEnum.Create: { if (objUserAccessViewModel.AddPermission == true) { isVisible = true; } break; } case ActionUserAccessEnum.Edit: { if (objUserAccessViewModel.EditPermission == true) { isVisible = true; } break; } case ActionUserAccessEnum.Delete: { if (objUserAccessViewModel.DeletePermission == true) { isVisible = true; } break; } case ActionUserAccessEnum.AdminOnly: { if (SessionWrapper.UserAccount.RoleId == RoleUserDefinedEnum.Admin.GetHashCode()) { isVisible = true; } break; } default: break; } } return(isVisible); }
private void CheckRoleUserAccess(ActionExecutingContext filterContext, UserAccessViewModel objUserAccessViewModel, Int16 RoleId) { var objUserAccessRepository = new UserAccessRepository(); objUserAccessViewModel = objUserAccessRepository.Select(UserAccessFlags.SelectPermissionByUrlRoleId.GetHashCode(), RoleId, objUserAccessViewModel).FirstOrDefault(); if (objUserAccessViewModel != null) { switch (ActionAccess) { case ActionUserAccessEnum.Default: break; case ActionUserAccessEnum.Index: { if (objUserAccessViewModel.ViewPermission != true && RoleId != RoleUserDefinedEnum.Admin.GetHashCode()) { RedirectUnAuthorizedUserLogin(filterContext); } break; } case ActionUserAccessEnum.Details: { if (objUserAccessViewModel.ViewPermission != true && RoleId != RoleUserDefinedEnum.Admin.GetHashCode()) { RedirectUnAuthorizedUserLogin(filterContext); } break; } case ActionUserAccessEnum.Create: { if (objUserAccessViewModel.AddPermission != true && RoleId != RoleUserDefinedEnum.Admin.GetHashCode()) { RedirectUnAuthorizedUserLogin(filterContext); } break; } case ActionUserAccessEnum.Edit: { if (objUserAccessViewModel.EditPermission != true && RoleId != RoleUserDefinedEnum.Admin.GetHashCode()) { RedirectUnAuthorizedUserLogin(filterContext); } break; } case ActionUserAccessEnum.Delete: { if (objUserAccessViewModel.DeletePermission != true && RoleId != RoleUserDefinedEnum.Admin.GetHashCode()) { RedirectUnAuthorizedUserLogin(filterContext); } break; } default: break; } } else { RedirectUnAuthorizedUserLogin(filterContext); } }