From 1000be0c89165fa4f0e07dc4c16dd2133f75793e Mon Sep 17 00:00:00 2001 From: TekH Date: Wed, 3 Dec 2025 09:52:25 +0100 Subject: [PATCH] Add enhancements to ActionController and CreateFakeAction Refactored ActionController to include IMediator dependency in the constructor. Updated CreateFakeAction method to: - Set a default value for `endpointUri`. - Add an optional `endpointPath` parameter and logic to construct a full URI. - Include the `Active` property in CreateRecActionCommand. - Ensure `endpointUri` is non-nullable. Also added the `System.IO` namespace for potential future use. --- src/ReC.API/Controllers/ActionController.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ReC.API/Controllers/ActionController.cs b/src/ReC.API/Controllers/ActionController.cs index 8684d2b..8c3d496 100644 --- a/src/ReC.API/Controllers/ActionController.cs +++ b/src/ReC.API/Controllers/ActionController.cs @@ -1,6 +1,7 @@ using MediatR; using Microsoft.AspNetCore.Mvc; using ReC.Application.RecActions.Commands; +using System.IO; namespace ReC.API.Controllers; @@ -25,16 +26,21 @@ public class ActionController(IMediator mediator) : ControllerBase [HttpPost("fake")] public async Task CreateFakeAction( - string? endpointUri = null, + string endpointUri = "https://jsonplaceholder.typicode.com/posts", + string? endpointPath = null, string type = "GET", string bodyQuery = "SELECT NULL AS REQUEST_BODY;") { + if (endpointPath is not null) + endpointUri = new Uri(new Uri(endpointUri.TrimEnd('/') + "/"), endpointPath.TrimStart('/')).ToString(); + await mediator.Send(new CreateRecActionCommand() { ProfileId = 2, EndpointUri = endpointUri, Type = type, - BodyQuery = bodyQuery + BodyQuery = bodyQuery, + Active = true, }); return CreatedAtAction(nameof(CreateFakeAction), null);