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.
This commit is contained in:
parent
3301b35067
commit
211d369509
@ -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<InvokeRecActionsCommandHandler>? logger = null
|
||||
) : IRequestHandler<InvokeRecActionCommand>
|
||||
{
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user