From 84d6e7a51132bacfbe1eb24fde34ad583c5ddefd Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 16 Jan 2026 10:13:33 +0100 Subject: [PATCH] Add EndpointParamsController for CRUD via procedures Introduced EndpointParamsController to manage endpoint parameter records using stored procedures. The controller supports POST (insert), PUT (update), and DELETE operations, leverages MediatR for command handling, and uses dependency injection for configuration and mediator services. Endpoints are documented and specify response types. --- .../Controllers/EndpointParamsController.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/ReC.API/Controllers/EndpointParamsController.cs 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(); + } +}