Rename ActionController to RecActionController

The `ActionController` class was removed and replaced with a new `RecActionController` class. The new class retains the same functionality, methods (`Invoke`, `CreateAction`, `CreateFakeAction`), and dependencies as the removed class.

The namespace (`ReC.API.Controllers`) and route attributes remain unchanged. Dependency injection for `IMediator` is preserved. This change is primarily a renaming of the controller to better align with its purpose while maintaining existing behavior.
This commit is contained in:
2025-12-03 10:39:34 +01:00
parent b5b1f53e21
commit 5b16d19541

View File

@@ -0,0 +1,54 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using ReC.API.Models;
using ReC.Application.RecActions.Commands;
using System.IO;
using System.Text.Json;
namespace ReC.API.Controllers;
[Route("api/[controller]")]
[ApiController]
public class RecActionController(IMediator mediator) : ControllerBase
{
[HttpPost("{profileId}")]
public async Task<IActionResult> Invoke([FromRoute] int profileId)
{
await mediator.InvokeBatchRecAction(profileId);
return Accepted();
}
[HttpPost]
public async Task<IActionResult> CreateAction([FromBody] CreateRecActionCommand command)
{
await mediator.Send(command);
return CreatedAtAction(nameof(CreateAction), null);
}
[HttpPost("fake")]
public async Task<IActionResult> CreateFakeAction(
[FromBody] FakeRequest? request = null,
[FromQuery] string endpointUri = "https://jsonplaceholder.typicode.com/posts",
[FromQuery] string? endpointPath = null,
[FromQuery] string type = "GET")
{
if (endpointPath is not null)
endpointUri = new Uri(new Uri(endpointUri.TrimEnd('/') + "/"), endpointPath.TrimStart('/')).ToString();
var bodyJson = request?.Body is not null ? JsonSerializer.Serialize(request.Body, options: new() { WriteIndented = false }) : null;
var headerJson = request?.Header is not null ? JsonSerializer.Serialize(request.Header, options: new() { WriteIndented = false }) : null;
await mediator.Send(new CreateRecActionCommand()
{
ProfileId = 2,
EndpointUri = endpointUri,
Type = type,
BodyQuery = $@"SELECT '{bodyJson ?? "NULL"}' AS REQUEST_BODY;",
HeaderQuery = headerJson is not null ? $@"SELECT '{headerJson}' AS REQUEST_HEADER;" : null,
Active = true
});
return CreatedAtAction(nameof(CreateFakeAction), null);
}
}