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:
@@ -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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user