public BindingList <UserAccessPermissionsModel> GetCustomAccessPermissionForUser(int employeeID) { BindingList <UserAccessPermissionsModel> list = new BindingList <UserAccessPermissionsModel>(); try { List <TBL_User_CustomPermissions> lstCustomPermissions = _dbContext.TBL_User_CustomPermissions.Where(x => x.fk_EmployeeId == employeeID).ToList(); foreach (TBL_User_CustomPermissions customPermission in lstCustomPermissions) { UserAccessPermissionsModel listItem = new UserAccessPermissionsModel() { ID = customPermission.pk_CustomPermissionID, FormID = customPermission.fk_FormId, FormName = customPermission.Tbl_MP_Master_Module_Forms.DisplayName, ModuleID = (int)customPermission.fk_ModuleId, ModuleName = customPermission.Tbl_MP_Master_Module.DisplayName, RoleID = 0, RoleName = "CUSTOM" }; string strDescription = string.Empty; if (customPermission.CanAddNew) { strDescription += "ADD "; } if (customPermission.CanApprove) { strDescription += "APPROVE "; } if (customPermission.CanAuthorize) { strDescription += "AUTHORIZE "; } if (customPermission.CanCheck) { strDescription += "CHECK "; } if (customPermission.CanDelete) { strDescription += "DELETE "; } if (customPermission.CanModify) { strDescription += "MODIFY "; } if (customPermission.CanPrepare) { strDescription += "PREPARE "; } if (customPermission.CanPrint) { strDescription += "PRINT "; } if (customPermission.CanView) { strDescription += "VIEW "; } listItem.Permissions = strDescription; list.Add(listItem); } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceUsers::GetCustomAccessPermissionForUser", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(list); }
public BindingList <UserAccessPermissionsModel> GetRoleWiseAccessPermissionForUser(int userID) { BindingList <UserAccessPermissionsModel> list = new BindingList <UserAccessPermissionsModel>(); try { TBL_User_Master user = this.GetUserDBModelByUserID(userID); if (user != null) { int roleID = (int)user.FK_RoleId; List <TBL_MP_Master_RoleForm> lstRoleForms = _dbContext.TBL_MP_Master_RoleForm.Where(x => x.FK_RoleID == roleID).ToList(); foreach (TBL_MP_Master_RoleForm roleForm in lstRoleForms) { UserAccessPermissionsModel listItem = new UserAccessPermissionsModel() { ID = roleForm.PK_RoleFormID, FormID = roleForm.FK_FormId, FormName = roleForm.Tbl_MP_Master_Module_Forms.DisplayName, ModuleID = (int)roleForm.FK_ModuleId, ModuleName = roleForm.Tbl_MP_Master_Module.DisplayName, RoleID = roleForm.FK_RoleID, RoleName = roleForm.TBL_MP_Master_Role.RoleName }; string strDescription = string.Empty; if (roleForm.CanAddNew) { strDescription += "ADD "; } if (roleForm.CanApprove) { strDescription += "APPROVE "; } if (roleForm.CanAuthorize) { strDescription += "AUTHORIZE "; } if (roleForm.CanCheck) { strDescription += "CHECK "; } if (roleForm.CanDelete) { strDescription += "DELETE "; } if (roleForm.CanModify) { strDescription += "MODIFY "; } if (roleForm.CanPrepare) { strDescription += "PREPARE "; } if (roleForm.CanPrint) { strDescription += "PRINT "; } if (roleForm.CanView) { strDescription += "VIEW "; } listItem.Permissions = strDescription; list.Add(listItem); } } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceUsers::GetRoleWiseAccessPermissionForUser", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(list); }