public bool GetSpecificPermissionValue(PermissionRequest permissionRequest) { bool hasPermission = false; try { int currentUser; ThingReader <CalculatedPermission> calculatedPermissionReader; currentUser = System.Convert.ToInt32(OperationContext.Current.IncomingMessageProperties["edge-user-id"]); List <CalculatedPermission> calculatedPermissionList = new List <CalculatedPermission>(); using (DataManager.Current.OpenConnection()) { SqlCommand sqlCommand = DataManager.CreateCommand("User_CalculatePermissions(@UserID:Int)", CommandType.StoredProcedure); sqlCommand.Parameters["@UserID"].Value = currentUser; calculatedPermissionReader = new ThingReader <CalculatedPermission>(sqlCommand.ExecuteReader(), null); while (calculatedPermissionReader.Read()) { calculatedPermissionList.Add(calculatedPermissionReader.Current); } calculatedPermissionReader.Dispose(); } if (calculatedPermissionList != null && calculatedPermissionList.Count > 0) { if (string.IsNullOrEmpty(permissionRequest.Path)) { if (calculatedPermissionList.Count > 0) { CalculatedPermission calculatedPermissions = calculatedPermissionList.Find(calculatedPermission => calculatedPermission.AccountID == permissionRequest.AccountID); if (calculatedPermissions != null) { hasPermission = true; } } } else { CalculatedPermission calculatedPermissions = calculatedPermissionList.Find(calculatedPermission => calculatedPermission.AccountID == permissionRequest.AccountID && calculatedPermission.Path.Trim().ToUpper() == permissionRequest.Path.Trim().ToUpper()); if (calculatedPermissions != null) { hasPermission = true; } } } } catch (Exception ex) { ErrorMessageInterceptor.ThrowError(HttpStatusCode.InternalServerError, ex.Message); } return(hasPermission); }
public bool GetSpecificPermissionValue(PermissionRequest permissionRequest) //TODO: CHANGE TO GET { bool hasPermission = false; int currentUser; ThingReader <CalculatedPermission> calculatedPermissionReader; currentUser = System.Convert.ToInt32(CurrentContext.Request.Headers["edge-user-id"]); List <CalculatedPermission> calculatedPermissionList = new List <CalculatedPermission>(); using (SqlConnection conn = new SqlConnection(AppSettings.GetConnectionString("Easynet.Edge.Core.Data.DataManager.Connection", "String"))) { SqlCommand sqlCommand = DataManager.CreateCommand("User_CalculatePermissions(@UserID:Int)", CommandType.StoredProcedure); sqlCommand.Connection = conn; conn.Open(); sqlCommand.Parameters["@UserID"].Value = currentUser; calculatedPermissionReader = new ThingReader <CalculatedPermission>(sqlCommand.ExecuteReader(), null); while (calculatedPermissionReader.Read()) { calculatedPermissionList.Add(calculatedPermissionReader.Current); } calculatedPermissionReader.Dispose(); } if (calculatedPermissionList != null && calculatedPermissionList.Count > 0) { if (string.IsNullOrEmpty(permissionRequest.Path)) { if (calculatedPermissionList.Count > 0) { CalculatedPermission calculatedPermissions = calculatedPermissionList.Find(calculatedPermission => calculatedPermission.AccountID == permissionRequest.AccountID); if (calculatedPermissions != null) { hasPermission = true; } } } else { CalculatedPermission calculatedPermissions = calculatedPermissionList.Find(calculatedPermission => calculatedPermission.AccountID == permissionRequest.AccountID && calculatedPermission.Path.Trim().ToUpper() == permissionRequest.Path.Trim().ToUpper()); if (calculatedPermissions != null) { hasPermission = true; } } } return(hasPermission); }