diff --git a/src/ReC.API/Controllers/RecActionController.cs b/src/ReC.API/Controllers/RecActionController.cs index f158983..d0edc38 100644 --- a/src/ReC.API/Controllers/RecActionController.cs +++ b/src/ReC.API/Controllers/RecActionController.cs @@ -21,12 +21,11 @@ public class RecActionController(IMediator mediator) : ControllerBase [ProducesResponseType(StatusCodes.Status202Accepted)] public async Task Invoke([FromRoute] long profileId, [FromBody] InvokeReferences references, CancellationToken cancel = default) { - await mediator.Send(new InvokeBatchRecActionViewsCommand + return Ok(await mediator.Send(new InvokeBatchRecActionViewsCommand { ProfileId = profileId, References = references - }, cancel); - return Accepted(); + }, cancel)); } #region CRUD diff --git a/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionViewsCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionViewsCommand.cs index c44e927..10ed064 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionViewsCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionViewsCommand.cs @@ -6,16 +6,26 @@ using ReC.Domain.Constants; namespace ReC.Application.RecActions.Commands; -public record InvokeBatchRecActionViewsCommand : IRequest +public record InvokeBatchRecActionViewsCommand : IRequest { public long ProfileId { get; init; } public required InvokeReferences References { get; init; } } -public class InvokeRecActionViewsCommandHandler(ISender sender, ILogger? logger = null) : IRequestHandler +public record BatchRecActionViewResponse { - public async Task Handle(InvokeBatchRecActionViewsCommand request, CancellationToken cancel) + public int TotalActionCount => SuccessCount + FailureCount; + + public int SuccessCount { get; internal set; } = 0; + + public int FailureCount { get; internal set; } = 0; +} + +public class InvokeRecActionViewsCommandHandler(ISender sender, ILogger? logger = null) : IRequestHandler +{ + public async Task Handle(InvokeBatchRecActionViewsCommand request, CancellationToken cancel) { + var res = new BatchRecActionViewResponse(); var actions = await sender.Send(new ReadRecActionViewQuery() { ProfileId = request.ProfileId }, cancel); foreach (var action in actions) @@ -27,31 +37,29 @@ public class InvokeRecActionViewsCommandHandler(ISender sender, ILogger