From 89238cc2d1ce7336f496385f61e2f5f28be704ff Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 16 Jan 2026 10:12:11 +0100 Subject: [PATCH] Add EndpointAuthController with CRUD endpoints Introduced EndpointAuthController to manage endpoint authentication records via MediatR and procedure-based commands. Added POST (insert), PUT (update), and DELETE (range delete) endpoints. Controller uses dependency injection and provides XML documentation for each action. --- .../Controllers/EndpointAuthController.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/ReC.API/Controllers/EndpointAuthController.cs diff --git a/src/ReC.API/Controllers/EndpointAuthController.cs b/src/ReC.API/Controllers/EndpointAuthController.cs new file mode 100644 index 0000000..af767f3 --- /dev/null +++ b/src/ReC.API/Controllers/EndpointAuthController.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.EndpointAuth.Commands; + +namespace ReC.API.Controllers; + +[Route("api/[controller]")] +[ApiController] +public class EndpointAuthController(IMediator mediator, IConfiguration config) : ControllerBase +{ + /// + /// Inserts an endpoint authentication record via the ENDPOINT_AUTH insert procedure. + /// + /// InsertEndpointAuthProcedure payload. + /// A token to cancel the operation. + /// The created ENDPOINT_AUTH identifier. + [HttpPost] + [ProducesResponseType(StatusCodes.Status201Created)] + public async Task Post([FromBody] InsertEndpointAuthProcedure procedure, CancellationToken cancel) + { + var id = await mediator.ExecuteInsertProcedure(procedure, config["AddedWho"], cancel); + return StatusCode(StatusCodes.Status201Created, id); + } + + /// + /// Updates an endpoint authentication record via the ENDPOINT_AUTH update procedure. + /// + /// ENDPOINT_AUTH identifier to update. + /// UpdateEndpointAuthProcedure 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] UpdateEndpointAuthProcedure procedure, CancellationToken cancel) + { + await mediator.ExecuteUpdateProcedure(procedure, id, cancel: cancel); + return NoContent(); + } + + /// + /// Deletes endpoint authentication records via the ENDPOINT_AUTH delete procedure for the specified id range. + /// + /// DeleteEndpointAuthProcedure payload (Start, End, Force). + /// A token to cancel the operation. + /// No content on success. + [HttpDelete] + [ProducesResponseType(StatusCodes.Status204NoContent)] + public async Task Delete([FromBody] DeleteEndpointAuthProcedure procedure, CancellationToken cancel) + { + await mediator.ExecuteDeleteProcedure(procedure, cancel); + return NoContent(); + } +}