Add POST endpoint to create ResultView in controller

Added a new HTTP POST action to ResultViewController that accepts a CreateResultViewCommand in the request body. On success, it returns a 201 Created response with a reference to the Get action for the created resource. This enables clients to create new ResultView entries via the API.
This commit is contained in:
2025-12-17 11:17:14 +01:00
parent 0fa1a418de
commit 9b800dce20

View File

@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Mvc;
using ReC.API.Extensions;
using ReC.API.Models;
using ReC.Application.ResultViews.Commands;
using ReC.Application.ResultViews.Queries;
namespace ReC.API.Controllers;
@@ -38,4 +39,11 @@ public class ResultViewController(IMediator mediator, IConfiguration config) : C
_ => Ok(res),
};
}
[HttpPost]
public async Task<IActionResult> Create([FromBody] CreateResultViewCommand command, CancellationToken cancel)
{
await mediator.Send(command, cancel);
return CreatedAtAction(nameof(Get), new { actionId = command.ActionId }, command);
}
}