Skip to content

Commit

Permalink
Rename for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
bkoelman committed Nov 27, 2024
1 parent ca2cda0 commit d98a732
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ protected virtual void ValidateEnabledOperations(IList<OperationContainer> opera
for (int operationIndex = 0; operationIndex < operations.Count; operationIndex++)
{
IJsonApiRequest operationRequest = operations[operationIndex].Request;
WriteOperationKind operationKind = operationRequest.WriteOperation!.Value;
WriteOperationKind writeOperation = operationRequest.WriteOperation!.Value;

if (operationRequest.Relationship != null && !_operationFilter.IsEnabled(operationRequest.Relationship.LeftType, operationKind))
if (operationRequest.Relationship != null && !_operationFilter.IsEnabled(operationRequest.Relationship.LeftType, writeOperation))
{
string operationCode = GetOperationCodeText(operationKind);
string operationCode = GetOperationCodeText(writeOperation);

errors.Add(new ErrorObject(HttpStatusCode.Forbidden)
{
Expand All @@ -153,9 +153,9 @@ protected virtual void ValidateEnabledOperations(IList<OperationContainer> opera
}
});
}
else if (operationRequest.PrimaryResourceType != null && !_operationFilter.IsEnabled(operationRequest.PrimaryResourceType, operationKind))
else if (operationRequest.PrimaryResourceType != null && !_operationFilter.IsEnabled(operationRequest.PrimaryResourceType, writeOperation))
{
string operationCode = GetOperationCodeText(operationKind);
string operationCode = GetOperationCodeText(writeOperation);

errors.Add(new ErrorObject(HttpStatusCode.Forbidden)
{
Expand All @@ -175,17 +175,17 @@ protected virtual void ValidateEnabledOperations(IList<OperationContainer> opera
}
}

private static string GetOperationCodeText(WriteOperationKind operationKind)
private static string GetOperationCodeText(WriteOperationKind writeOperation)
{
AtomicOperationCode operationCode = operationKind switch
AtomicOperationCode operationCode = writeOperation switch
{
WriteOperationKind.CreateResource => AtomicOperationCode.Add,
WriteOperationKind.UpdateResource => AtomicOperationCode.Update,
WriteOperationKind.DeleteResource => AtomicOperationCode.Remove,
WriteOperationKind.AddToRelationship => AtomicOperationCode.Add,
WriteOperationKind.SetRelationship => AtomicOperationCode.Update,
WriteOperationKind.RemoveFromRelationship => AtomicOperationCode.Remove,
_ => throw new NotSupportedException($"Unknown operation kind '{operationKind}'.")
_ => throw new NotSupportedException($"Unknown operation kind '{writeOperation}'.")
};

return operationCode.ToString().ToLowerInvariant();
Expand Down

0 comments on commit d98a732

Please sign in to comment.