From 211d369509dbd607b6c42651cd65b8293844e1bc Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 1 Dec 2025 11:39:41 +0100 Subject: [PATCH] Add CreateOutResCommand handling to RecActionCommand Enhanced InvokeRecActionCommandHandler to send a CreateOutResCommand after processing HTTP responses. Added dependencies for configuration and command handling. Updated the constructor to include ISender and optional IConfiguration for improved extensibility. --- .../RecActions/Commands/InvokeRecActionCommand.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs index 60ee956..cb3a936 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs @@ -1,7 +1,10 @@ using MediatR; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using ReC.Application.Common; using ReC.Application.Common.Dto; +using ReC.Application.OutResults.Commands; +using System.Text.Json; namespace ReC.Application.RecActions.Commands; @@ -18,7 +21,9 @@ public static class InvokeRecActionCommandExtensions } public class InvokeRecActionCommandHandler( - IHttpClientFactory clientFactory, + ISender sender, + IHttpClientFactory clientFactory, + IConfiguration? config = null, ILogger? logger = null ) : IRequestHandler { @@ -53,5 +58,13 @@ public class InvokeRecActionCommandHandler( using var response = await http.SendAsync(httpReq, cancel); var resBody = await response.Content.ReadAsStringAsync(cancel); var resHeaders = response.Headers.ToDictionary(); + + await sender.Send(new CreateOutResCommand + { + ActionId = (long) request.ActionId!, + Header = JsonSerializer.Serialize(resHeaders, options: new() { WriteIndented = false }), + Body = resBody, + AddedWho = config?["AddedWho"] + }, cancel); } } \ No newline at end of file