Refactor RestType null check with pattern matching

Refactored the null check for action.RestType to use pattern matching, assigning it to a local variable restType if not null. Now throws DataIntegrityException if RestType is null, and uses restType for creating the HttpRequestMessage. This improves code clarity and ensures RestType is non-null in subsequent logic.
This commit is contained in:
2025-12-15 12:53:43 +01:00
parent e529027587
commit 42fd176fad

View File

@@ -35,14 +35,14 @@ public class InvokeRecActionViewCommandHandler(
using var http = clientFactory.CreateClient(Http.ClientName); using var http = clientFactory.CreateClient(Http.ClientName);
if (action.RestType is null) if (action.RestType is not RestType restType)
throw new DataIntegrityException( throw new DataIntegrityException(
$"Rec action could not be invoked because the RestType value is null. " + $"Rec action could not be invoked because the RestType value is null. " +
$"ProfileId: {action.ProfileId}, " + $"ProfileId: {action.ProfileId}, " +
$"Id: {action.Id}" $"Id: {action.Id}"
); );
using var httpReq = action.RestType using var httpReq = restType
.ToHttpMethod() .ToHttpMethod()
.ToHttpRequestMessage(action.EndpointUri); .ToHttpRequestMessage(action.EndpointUri);