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.
17 lines
519 B
C#
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);
|
|
}
|
|
} |