From d2e97a2fef194dd699beb1c1360109329b2c730b Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 24 Mar 2026 11:02:58 +0100 Subject: [PATCH] Refactor EndpointParamsController to use MediatR.Send Removed IConfiguration dependency and custom MediatR extension methods from EndpointParamsController. All command handling now uses mediator.Send directly, and route/config parameters have been eliminated from endpoints. Cleaned up unused usings and streamlined controller logic. --- .../Controllers/EndpointParamsController.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/ReC.API/Controllers/EndpointParamsController.cs b/src/ReC.API/Controllers/EndpointParamsController.cs index 47e6e70..3c675be 100644 --- a/src/ReC.API/Controllers/EndpointParamsController.cs +++ b/src/ReC.API/Controllers/EndpointParamsController.cs @@ -1,15 +1,12 @@ 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 +public class EndpointParamsController(IMediator mediator) : ControllerBase { /// /// Inserts endpoint parameter records via the ENDPOINT_PARAMS insert procedure. @@ -21,22 +18,21 @@ public class EndpointParamsController(IMediator mediator, IConfiguration config) [ProducesResponseType(StatusCodes.Status201Created)] public async Task Post([FromBody] InsertEndpointParamsProcedure procedure, CancellationToken cancel) { - var id = await mediator.ExecuteInsertProcedure(procedure, config["AddedWho"], cancel); + var id = await mediator.Send(procedure, 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}")] + [HttpPut] [ProducesResponseType(StatusCodes.Status204NoContent)] - public async Task Put([FromRoute] long id, [FromBody] UpdateEndpointParamsProcedure procedure, CancellationToken cancel) + public async Task Put([FromBody] UpdateEndpointParamsProcedure procedure, CancellationToken cancel) { - await mediator.ExecuteUpdateProcedure(procedure, id, cancel: cancel); + await mediator.Send(procedure, cancel); return NoContent(); } @@ -50,7 +46,7 @@ public class EndpointParamsController(IMediator mediator, IConfiguration config) [ProducesResponseType(StatusCodes.Status204NoContent)] public async Task Delete([FromBody] DeleteEndpointParamsProcedure procedure, CancellationToken cancel) { - await mediator.ExecuteDeleteProcedure(procedure, cancel); + await mediator.Send(procedure, cancel); return NoContent(); } }