Move AddedWho config to RecActionOptions and refactor usage
Centralize AddedWho under RecAction in appsettings.json and add it to RecActionOptions. Update InvokeRecActionViewCommandHandler to use IOptions<RecActionOptions> for strongly-typed configuration access, replacing previous config-based retrieval. Removes global AddedWho property for improved maintainability.
This commit is contained in:
@@ -20,11 +20,14 @@ public record InvokeRecActionViewCommand : IRequest<bool>
|
||||
}
|
||||
|
||||
public class InvokeRecActionViewCommandHandler(
|
||||
IOptions<RecActionOptions> options,
|
||||
ISender sender,
|
||||
IHttpClientFactory clientFactory,
|
||||
IConfiguration? config = null
|
||||
) : IRequestHandler<InvokeRecActionViewCommand, bool>
|
||||
{
|
||||
private readonly RecActionOptions _options = options.Value;
|
||||
|
||||
public async Task<bool> Handle(InvokeRecActionViewCommand request, CancellationToken cancel)
|
||||
{
|
||||
var action = request.Action;
|
||||
@@ -135,7 +138,7 @@ public class InvokeRecActionViewCommandHandler(
|
||||
ActionId = action.Id,
|
||||
Header = JsonSerializer.Serialize(resHeaders, options: new() { WriteIndented = false }),
|
||||
Body = resBody
|
||||
}, config?["AddedWho"], cancel);
|
||||
}, _options.AddedWho, cancel);
|
||||
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user