From f78619278606b8eeb1362862f3d254c07d518030 Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 24 Mar 2026 11:07:42 +0100 Subject: [PATCH] Refactor ResultController to use mediator.Send for commands Standardize command handling by replacing custom mediator methods with mediator.Send in ResultController. Update PUT endpoint to remove id route parameter and rely on payload for identification. --- src/ReC.API/Controllers/ResultController.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ReC.API/Controllers/ResultController.cs b/src/ReC.API/Controllers/ResultController.cs index b893c74..c5448fb 100644 --- a/src/ReC.API/Controllers/ResultController.cs +++ b/src/ReC.API/Controllers/ResultController.cs @@ -32,22 +32,21 @@ public class ResultController(IMediator mediator) : ControllerBase [ProducesResponseType(StatusCodes.Status201Created)] public async Task Post([FromBody] InsertResultProcedure procedure, CancellationToken cancel) { - var id = await mediator.ExecuteInsertProcedure(procedure, cancel: cancel); + var id = await mediator.Send(procedure, cancel); return CreatedAtAction(nameof(Get), new { actionId = procedure.ActionId }, new { id, procedure.ActionId }); } /// /// Updates a RESULT record via the update procedure. /// - /// RESULT identifier to update. /// UpdateResultProcedure 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] UpdateResultProcedure procedure, CancellationToken cancel) + public async Task Put([FromBody] UpdateResultProcedure procedure, CancellationToken cancel) { - await mediator.ExecuteUpdateProcedure(procedure, id, cancel: cancel); + await mediator.Send(procedure, cancel); return NoContent(); } @@ -61,7 +60,7 @@ public class ResultController(IMediator mediator) : ControllerBase [ProducesResponseType(StatusCodes.Status204NoContent)] public async Task Delete([FromBody] DeleteResultProcedure procedure, CancellationToken cancel) { - await mediator.ExecuteDeleteProcedure(procedure, cancel); + await mediator.Send(procedure, cancel); return NoContent(); } } \ No newline at end of file