Refactor OutResController to use DeleteResultProcedure
Refactored DELETE endpoints in OutResController to use the new DeleteResultProcedure payload instead of DeleteOutResCommand. Updated endpoints to call mediator.ExecuteDeleteProcedure and revised XML docs accordingly. Removed obsolete attributes and command references. The "fake" profile deletion now uses the procedure with the fake profile ID.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReC.API.Extensions;
|
||||
using ReC.API.Models;
|
||||
using ReC.Application.OutResults.Commands;
|
||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
using ReC.Application.OutResults.Queries;
|
||||
|
||||
namespace ReC.API.Controllers;
|
||||
@@ -59,32 +59,36 @@ public class OutResController(IMediator mediator, IConfiguration config) : Contr
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes output results based on the provided criteria.
|
||||
/// Deletes RESULT records via the delete procedure for the specified id range.
|
||||
/// </summary>
|
||||
/// <param name="command">The command containing the deletion criteria, such as ActionId or ProfileId.</param>
|
||||
/// <param name="procedure">DeleteResultProcedure payload (Start, End, Force).</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>An empty response indicating success.</returns>
|
||||
/// <returns>No content on success.</returns>
|
||||
[HttpDelete]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[Obsolete("Use the related procedure or view.")]
|
||||
public async Task<IActionResult> Delete([FromQuery] DeleteOutResCommand command, CancellationToken cancel)
|
||||
public async Task<IActionResult> Delete([FromBody] DeleteResultProcedure procedure, CancellationToken cancel)
|
||||
{
|
||||
await mediator.Send(command, cancel);
|
||||
await mediator.ExecuteDeleteProcedure(procedure, cancel);
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all output results for a fake/test profile.
|
||||
/// Deletes RESULT records for a fake/test profile via the delete procedure.
|
||||
/// </summary>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>An empty response indicating success.</returns>
|
||||
/// <returns>No content on success.</returns>
|
||||
[HttpDelete("fake")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Obsolete("Use the related procedure or view.")]
|
||||
public async Task<IActionResult> Delete(CancellationToken cancel)
|
||||
{
|
||||
await mediator.Send(new DeleteOutResCommand() { ProfileId = config.GetFakeProfileId() }, cancel);
|
||||
await mediator.ExecuteDeleteProcedure(new DeleteResultProcedure
|
||||
{
|
||||
Start = config.GetFakeProfileId(),
|
||||
End = config.GetFakeProfileId(),
|
||||
Force = false
|
||||
}, cancel);
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user