From 13e65774ccce62212b891c7baaf4d67e3f656fcb Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 16 Jan 2026 10:01:08 +0100 Subject: [PATCH] Add procedure-based update and delete endpoints to controller Refactored RecActionController to support update via a new PUT endpoint using UpdateActionProcedure. Changed DELETE endpoints to use DeleteActionProcedure payloads instead of command objects, removing obsolete attributes. Updated using statements for new procedure types and standardized payload handling for update and delete operations. --- .../Controllers/RecActionController.cs | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/ReC.API/Controllers/RecActionController.cs b/src/ReC.API/Controllers/RecActionController.cs index 9bfebdf..d626636 100644 --- a/src/ReC.API/Controllers/RecActionController.cs +++ b/src/ReC.API/Controllers/RecActionController.cs @@ -1,7 +1,9 @@ using MediatR; using Microsoft.AspNetCore.Mvc; using ReC.API.Extensions; +using ReC.Application.Common.Procedures.DeleteProcedure; using ReC.Application.Common.Procedures.InsertProcedure; +using ReC.Application.Common.Procedures.UpdateProcedure; using ReC.Application.RecActions.Commands; using ReC.Application.RecActions.Queries; @@ -79,33 +81,48 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co } /// - /// Deletes all RecActions associated with a specific profile. + /// Updates a RecAction via the ACTION update procedure. /// - /// + /// RecAction identifier to update. + /// UpdateActionProcedure payload. + /// A token to cancel the operation. + /// No content on success. + [HttpPut("{id:long}")] + [ProducesResponseType(StatusCodes.Status204NoContent)] + public async Task UpdateAction([FromRoute] long id, [FromBody] UpdateActionProcedure procedure, CancellationToken cancel) + { + await mediator.ExecuteUpdateProcedure(procedure, id, cancel: cancel); + return NoContent(); + } + + /// + /// Deletes RecActions via the ACTION delete procedure for the specified id range. + /// + /// DeleteActionProcedure payload (Start, End, Force). /// A token to cancel the operation. /// An HTTP 204 No Content response upon successful deletion. [HttpDelete] [ProducesResponseType(StatusCodes.Status204NoContent)] - [Obsolete("Use the related procedure.")] - public async Task Delete([FromQuery] DeleteRecActionsCommand cmd, CancellationToken cancel) + public async Task Delete([FromBody] DeleteActionProcedure procedure, CancellationToken cancel) { - await mediator.Send(cmd, cancel); + await mediator.ExecuteDeleteProcedure(procedure, cancel); return NoContent(); } /// - /// Deletes all RecActions for a fake/test profile. + /// Deletes RecActions for a fake/test profile via the ACTION delete procedure. /// /// A token to cancel the operation. /// An HTTP 204 No Content response upon successful deletion. [HttpDelete("fake")] [ProducesResponseType(StatusCodes.Status204NoContent)] - [Obsolete("Use the related procedure.")] public async Task Delete(CancellationToken cancel) { - await mediator.Send(new DeleteRecActionsCommand() + await mediator.ExecuteDeleteProcedure(new DeleteActionProcedure { - ProfileId = config.GetFakeProfileId() + Start = config.GetFakeProfileId(), + End = config.GetFakeProfileId(), + Force = false }, cancel); return NoContent();