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:
@@ -8,7 +8,7 @@ using System.Text.Json;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
|
||||
public record InvokeRecActionCommand : IRequest
|
||||
public record InvokeRecActionCommand : IRequest<bool>
|
||||
{
|
||||
public RecActionDto Action { get; set; } = null!;
|
||||
}
|
||||
@@ -22,9 +22,9 @@ public class InvokeRecActionCommandHandler(
|
||||
ISender sender,
|
||||
IHttpClientFactory clientFactory,
|
||||
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;
|
||||
using var http = clientFactory.CreateClient();
|
||||
@@ -64,5 +64,7 @@ public class InvokeRecActionCommandHandler(
|
||||
Body = resBody,
|
||||
AddedWho = config?["AddedWho"]
|
||||
}, cancel);
|
||||
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user