From 42fd176fad4ebf0687b101c1eddd2d0e304d74ae Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 15 Dec 2025 12:53:43 +0100 Subject: [PATCH] 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. --- .../RecActionViews/Commands/InvokeRecActionViewCommand.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ReC.Application/RecActionViews/Commands/InvokeRecActionViewCommand.cs b/src/ReC.Application/RecActionViews/Commands/InvokeRecActionViewCommand.cs index 2f790f1..b73aaa8 100644 --- a/src/ReC.Application/RecActionViews/Commands/InvokeRecActionViewCommand.cs +++ b/src/ReC.Application/RecActionViews/Commands/InvokeRecActionViewCommand.cs @@ -35,14 +35,14 @@ public class InvokeRecActionViewCommandHandler( using var http = clientFactory.CreateClient(Http.ClientName); - if (action.RestType is null) + if (action.RestType is not RestType restType) throw new DataIntegrityException( $"Rec action could not be invoked because the RestType value is null. " + $"ProfileId: {action.ProfileId}, " + $"Id: {action.Id}" ); - using var httpReq = action.RestType + using var httpReq = restType .ToHttpMethod() .ToHttpRequestMessage(action.EndpointUri);