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.
This commit is contained in:
2025-12-01 16:48:05 +01:00
parent a27000a75b
commit 8624742eb3
2 changed files with 21 additions and 3 deletions

View File

@@ -19,6 +19,24 @@ public class ActionController(IMediator mediator) : ControllerBase
public async Task<IActionResult> CreateAction([FromBody] CreateRecActionCommand command)
{
await mediator.Send(command);
return CreatedAtAction(nameof(CreateAction), null);
}
[HttpPost("fake")]
public async Task<IActionResult> 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);
}
}

View File

@@ -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<CreateRecActionCommand>