Files
ReC/src/ReC.API/Controllers/CommonController.cs
TekH 3864b0f68b Add CommonController with POST endpoint using MediatR
Introduced CommonController in the ReC.API.Controllers namespace with a POST endpoint at "api/common". The endpoint accepts an InsertObjectProcedure from the request body, sends it via MediatR, and returns a 201 Created response with the generated ID.
2026-01-14 13:13:23 +01:00

17 lines
519 B
C#

using MediatR;
using Microsoft.AspNetCore.Mvc;
using ReC.Application.Common.Procedures.InsertProcedure;
namespace ReC.API.Controllers;
[Route("api/[controller]")]
[ApiController]
public class CommonController(IMediator mediator) : ControllerBase
{
[HttpPost]
public async Task<IActionResult> CreateObject([FromBody] InsertObjectProcedure procedure, CancellationToken cancel)
{
var id = await mediator.Send(procedure, cancel);
return StatusCode(StatusCodes.Status201Created, id);
}
}