From 6de45e3feb302cc0a54157f262ae7c1a4ea76406 Mon Sep 17 00:00:00 2001 From: TekH Date: Wed, 3 Dec 2025 13:49:26 +0100 Subject: [PATCH] Refactor RecActionController and add new endpoints - Introduced `FakeProfileId` constant to replace hardcoded values. - Added `HttpGet` endpoint `api/[controller]/fake` to retrieve data using `FakeProfileId`. - Added `HttpPost` endpoint `api/[controller]/invoke/{profileId}` for batch actions. - Updated `CreateAction` and `Delete` methods to use `FakeProfileId`. - Added `HttpDelete` endpoint `api/[controller]/fake` to delete actions using `FakeProfileId`. - Improved code maintainability by centralizing the fake profile ID and adding dedicated endpoints. --- src/ReC.API/Controllers/RecActionController.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ReC.API/Controllers/RecActionController.cs b/src/ReC.API/Controllers/RecActionController.cs index 8b67ef2..0ba1ed8 100644 --- a/src/ReC.API/Controllers/RecActionController.cs +++ b/src/ReC.API/Controllers/RecActionController.cs @@ -11,6 +11,8 @@ namespace ReC.API.Controllers; [ApiController] public class RecActionController(IMediator mediator) : ControllerBase { + private const long FakeProfileId = 2; + [HttpPost("invoke/{profileId}")] public async Task Invoke([FromRoute] int profileId, CancellationToken cancel) { @@ -25,6 +27,12 @@ public class RecActionController(IMediator mediator) : ControllerBase ProfileId = profileId }, cancel)); + [HttpGet("fake")] + public async Task Get(CancellationToken cancel) => Ok(await mediator.Send(new ReadRecActionQuery() + { + ProfileId = FakeProfileId + }, cancel)); + [HttpPost] public async Task CreateAction([FromBody] CreateRecActionCommand command, CancellationToken cancel) { @@ -49,7 +57,7 @@ public class RecActionController(IMediator mediator) : ControllerBase await mediator.Send(new CreateRecActionCommand() { - ProfileId = 2, + ProfileId = FakeProfileId, EndpointUri = endpointUri, Type = type, BodyQuery = $@"SELECT '{bodyJson ?? "NULL"}' AS REQUEST_BODY;", @@ -66,7 +74,7 @@ public class RecActionController(IMediator mediator) : ControllerBase { await mediator.Send(new DeleteRecActionsCommand() { - ProfileId = profileId + ProfileId = FakeProfileId }, cancel); return NoContent(); @@ -77,7 +85,7 @@ public class RecActionController(IMediator mediator) : ControllerBase { await mediator.Send(new DeleteRecActionsCommand() { - ProfileId = 2 + ProfileId = FakeProfileId }, cancel); return NoContent();