Update InvokeRecActionCommand to return success status

Changed InvokeRecActionCommand and its handler to return a boolean indicating success or failure, allowing consumers to check if the action was successful. This improves clarity and error handling in command execution.
This commit is contained in:
2025-12-12 01:43:01 +01:00
parent da1b05347e
commit 71411d4027

View File

@@ -8,7 +8,7 @@ using System.Text.Json;
namespace ReC.Application.RecActions.Commands; namespace ReC.Application.RecActions.Commands;
public record InvokeRecActionCommand : IRequest public record InvokeRecActionCommand : IRequest<bool>
{ {
public RecActionDto Action { get; set; } = null!; public RecActionDto Action { get; set; } = null!;
} }
@@ -22,9 +22,9 @@ public class InvokeRecActionCommandHandler(
ISender sender, ISender sender,
IHttpClientFactory clientFactory, IHttpClientFactory clientFactory,
IConfiguration? config = null IConfiguration? config = null
) : IRequestHandler<InvokeRecActionCommand> ) : IRequestHandler<InvokeRecActionCommand, bool>
{ {
public async Task Handle(InvokeRecActionCommand request, CancellationToken cancel) public async Task<bool> Handle(InvokeRecActionCommand request, CancellationToken cancel)
{ {
var action = request.Action; var action = request.Action;
using var http = clientFactory.CreateClient(); using var http = clientFactory.CreateClient();
@@ -64,5 +64,7 @@ public class InvokeRecActionCommandHandler(
Body = resBody, Body = resBody,
AddedWho = config?["AddedWho"] AddedWho = config?["AddedWho"]
}, cancel); }, cancel);
return response.IsSuccessStatusCode;
} }
} }