From 8624742eb3659d8b6c4ad0504606ec1a7c3f5292 Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 1 Dec 2025 16:48:05 +0100 Subject: [PATCH] Add CreateFakeAction endpoint and update command defaults The ActionController class was updated to include a new CreateFakeAction endpoint. This endpoint accepts optional parameters (endpointUri, type, and bodyQuery) and sends a CreateRecActionCommand with hardcoded and default values. The CreateRecActionCommand record was modified to remove default values for ProfileId, Type, and BodyQuery. These properties now require explicit initialization, with Type and BodyQuery marked as non-nullable using the null! syntax. These changes improve flexibility and add support for creating "fake" actions via the new endpoint. --- src/ReC.API/Controllers/ActionController.cs | 18 ++++++++++++++++++ .../Commands/CreateRecActionCommand.cs | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/ReC.API/Controllers/ActionController.cs b/src/ReC.API/Controllers/ActionController.cs index 9a54481..8684d2b 100644 --- a/src/ReC.API/Controllers/ActionController.cs +++ b/src/ReC.API/Controllers/ActionController.cs @@ -19,6 +19,24 @@ public class ActionController(IMediator mediator) : ControllerBase public async Task CreateAction([FromBody] CreateRecActionCommand command) { await mediator.Send(command); + return CreatedAtAction(nameof(CreateAction), null); } + + [HttpPost("fake")] + public async Task CreateFakeAction( + string? endpointUri = null, + string type = "GET", + string bodyQuery = "SELECT NULL AS REQUEST_BODY;") + { + await mediator.Send(new CreateRecActionCommand() + { + ProfileId = 2, + EndpointUri = endpointUri, + Type = type, + BodyQuery = bodyQuery + }); + + return CreatedAtAction(nameof(CreateFakeAction), null); + } } \ No newline at end of file diff --git a/src/ReC.Application/RecActions/Commands/CreateRecActionCommand.cs b/src/ReC.Application/RecActions/Commands/CreateRecActionCommand.cs index 46bc918..c074fae 100644 --- a/src/ReC.Application/RecActions/Commands/CreateRecActionCommand.cs +++ b/src/ReC.Application/RecActions/Commands/CreateRecActionCommand.cs @@ -6,7 +6,7 @@ namespace ReC.Application.RecActions.Commands; public record CreateRecActionCommand : IRequest { - public long ProfileId { get; init; } = 2; + public long ProfileId { get; init; } public bool Active { get; init; } = true; @@ -14,11 +14,11 @@ public record CreateRecActionCommand : IRequest public string? EndpointUri { get; init; } - public string Type { get; init; } = "GET"; + public string Type { get; init; } = null!; public string? HeaderQuery { get; init; } - public string BodyQuery { get; init; } = "SELECT NULL AS REQUEST_BODY;"; + public string BodyQuery { get; init; } = null!; } public class CreateRecActionCommandHandler(ISender sender) : IRequestHandler