Endpoint to add a verspakket

This commit is contained in:
moarten
2026-04-17 22:02:25 +02:00
parent 0acc9a1f8e
commit a10bcfa1d6
17 changed files with 121 additions and 16 deletions

View File

@@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Mvc;
namespace Lutra.API.Controllers
{
/// <summary>
/// Provides read-only access to verspakket resources.
/// Provides access to verspakket resources.
/// </summary>
[ApiController]
[Route("api/verspakketten")]
@@ -50,5 +50,27 @@ namespace Lutra.API.Controllers
return Ok(result);
}
/// <summary>
/// Creates a new verspakket.
/// </summary>
/// <param name="command">The verspakket values to create.</param>
/// <returns>Returns 201 Created with the created verspakket identifier.</returns>
[HttpPost]
[ProducesResponseType(typeof(CreateVerspakket.Response), StatusCodes.Status201Created)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<ActionResult<CreateVerspakket.Response>> Post([FromBody] CreateVerspakket.Command command)
{
try
{
var result = await mediator.SendCommandAsync<CreateVerspakket.Command, CreateVerspakket.Response>(command);
return CreatedAtAction(nameof(GetById), new { id = result.Id }, result);
}
catch (InvalidOperationException ex)
{
return BadRequest(ex.Message);
}
}
}
}