Refactored all relevant controller DELETE actions to accept command/procedure parameters from the query string ([FromQuery]) instead of the request body ([FromBody]). Updated XML documentation and method signatures to reflect this change, including renaming parameters from "procedure" to "command" where appropriate. Also removed the unused IConfiguration dependency from EndpointAuthController.
52 lines
2.0 KiB
C#
52 lines
2.0 KiB
C#
using MediatR;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using ReC.Application.Endpoints.Commands;
|
|
|
|
namespace ReC.API.Controllers;
|
|
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class EndpointsController(IMediator mediator) : ControllerBase
|
|
{
|
|
/// <summary>
|
|
/// Inserts an endpoint via the ENDPOINT insert procedure.
|
|
/// </summary>
|
|
/// <param name="procedure">InsertEndpointProcedure payload.</param>
|
|
/// <param name="cancel">A token to cancel the operation.</param>
|
|
/// <returns>The created ENDPOINT identifier.</returns>
|
|
[HttpPost]
|
|
[ProducesResponseType(StatusCodes.Status201Created)]
|
|
public async Task<IActionResult> Post([FromBody] InsertEndpointCommand procedure, CancellationToken cancel)
|
|
{
|
|
var id = await mediator.Send(procedure, cancel);
|
|
return StatusCode(StatusCodes.Status201Created, id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates an endpoint via the ENDPOINT update procedure.
|
|
/// </summary>
|
|
/// <param name="procedure">UpdateEndpointProcedure payload.</param>
|
|
/// <param name="cancel">A token to cancel the operation.</param>
|
|
/// <returns>No content on success.</returns>
|
|
[HttpPut]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
public async Task<IActionResult> Put([FromBody] UpdateEndpointCommand procedure, CancellationToken cancel)
|
|
{
|
|
await mediator.Send(procedure, cancel);
|
|
return NoContent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Deletes endpoints via the ENDPOINT delete procedure for the specified id range.
|
|
/// </summary>
|
|
/// <param name="command">DeleteEndpointProcedure payload (Start, End, Force).</param>
|
|
/// <param name="cancel">A token to cancel the operation.</param>
|
|
/// <returns>No content on success.</returns>
|
|
[HttpDelete]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
public async Task<IActionResult> Delete([FromQuery] DeleteEndpointCommand command, CancellationToken cancel)
|
|
{
|
|
await mediator.Send(command, cancel);
|
|
return NoContent();
|
|
}
|
|
} |