diff --git a/src/ReC.API/Controllers/EndpointParamsController.cs b/src/ReC.API/Controllers/EndpointParamsController.cs new file mode 100644 index 0000000..47e6e70 --- /dev/null +++ b/src/ReC.API/Controllers/EndpointParamsController.cs @@ -0,0 +1,56 @@ +using MediatR; +using Microsoft.AspNetCore.Mvc; +using ReC.Application.Common.Procedures.DeleteProcedure; +using ReC.Application.Common.Procedures.InsertProcedure; +using ReC.Application.Common.Procedures.UpdateProcedure; +using ReC.Application.EndpointParams.Commands; + +namespace ReC.API.Controllers; + +[Route("api/[controller]")] +[ApiController] +public class EndpointParamsController(IMediator mediator, IConfiguration config) : ControllerBase +{ + /// + /// Inserts endpoint parameter records via the ENDPOINT_PARAMS insert procedure. + /// + /// InsertEndpointParamsProcedure payload. + /// A token to cancel the operation. + /// The created ENDPOINT_PARAMS identifier. + [HttpPost] + [ProducesResponseType(StatusCodes.Status201Created)] + public async Task Post([FromBody] InsertEndpointParamsProcedure procedure, CancellationToken cancel) + { + var id = await mediator.ExecuteInsertProcedure(procedure, config["AddedWho"], cancel); + return StatusCode(StatusCodes.Status201Created, id); + } + + /// + /// Updates endpoint parameter records via the ENDPOINT_PARAMS update procedure. + /// + /// ENDPOINT_PARAMS identifier to update. + /// UpdateEndpointParamsProcedure payload. + /// A token to cancel the operation. + /// No content on success. + [HttpPut("{id:long}")] + [ProducesResponseType(StatusCodes.Status204NoContent)] + public async Task Put([FromRoute] long id, [FromBody] UpdateEndpointParamsProcedure procedure, CancellationToken cancel) + { + await mediator.ExecuteUpdateProcedure(procedure, id, cancel: cancel); + return NoContent(); + } + + /// + /// Deletes endpoint parameter records via the ENDPOINT_PARAMS delete procedure for the specified id range. + /// + /// DeleteEndpointParamsProcedure payload (Start, End, Force). + /// A token to cancel the operation. + /// No content on success. + [HttpDelete] + [ProducesResponseType(StatusCodes.Status204NoContent)] + public async Task Delete([FromBody] DeleteEndpointParamsProcedure procedure, CancellationToken cancel) + { + await mediator.ExecuteDeleteProcedure(procedure, cancel); + return NoContent(); + } +}