From 606a6727f488a6c6d23e68bc2be10898407efa58 Mon Sep 17 00:00:00 2001 From: TekH Date: Wed, 3 Dec 2025 12:54:39 +0100 Subject: [PATCH] Refactor RecActionController and add CRUD methods Refactored the `RecActionController` to improve structure and readability by introducing a `#region CRUD` section. Updated the `HttpPost` route for invoking actions to `"invoke/{profileId}"`. Added a new `CreateAction` method to handle action creation and renamed the `HttpDelete` method from `GetActions` to `Delete` for clarity. Introduced the `Invoke` method for batch action invocation. Improved overall code organization and maintainability. --- src/ReC.API/Controllers/RecActionController.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ReC.API/Controllers/RecActionController.cs b/src/ReC.API/Controllers/RecActionController.cs index 524c886..9f90ce0 100644 --- a/src/ReC.API/Controllers/RecActionController.cs +++ b/src/ReC.API/Controllers/RecActionController.cs @@ -11,19 +11,20 @@ namespace ReC.API.Controllers; [ApiController] public class RecActionController(IMediator mediator) : ControllerBase { - [HttpGet] - public async Task Get([FromQuery] long profileId, CancellationToken cancel) => Ok(await mediator.Send(new ReadRecActionQuery() - { - ProfileId = profileId - }, cancel)); - - [HttpPost("{profileId}")] + [HttpPost("invoke/{profileId}")] public async Task Invoke([FromRoute] int profileId, CancellationToken cancel) { await mediator.InvokeBatchRecAction(profileId, cancel); return Accepted(); } + #region CRUD + [HttpGet] + public async Task Get([FromQuery] long profileId, CancellationToken cancel) => Ok(await mediator.Send(new ReadRecActionQuery() + { + ProfileId = profileId + }, cancel)); + [HttpPost] public async Task CreateAction([FromBody] CreateRecActionCommand command, CancellationToken cancel) { @@ -60,7 +61,7 @@ public class RecActionController(IMediator mediator) : ControllerBase } [HttpDelete] - public async Task GetActions([FromQuery] int profileId, CancellationToken cancel) + public async Task Delete([FromQuery] int profileId, CancellationToken cancel) { await mediator.Send(new DeleteRecActionsCommand() { @@ -69,4 +70,5 @@ public class RecActionController(IMediator mediator) : ControllerBase return NoContent(); } + #endregion CRUD } \ No newline at end of file