Files
monorepo/LCU.API.Internal.Dispatcher/LCU.Api.Internal.Dispatcher/Controllers/ExecutionMessageController.cs
T
2026-03-24 15:26:03 -05:00

43 lines
1.3 KiB
C#

using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using LCU.Api.Internal.Dispatcher.Services;
namespace LCU.Api.Internal.Dispatcher.Controllers;
[Route("[controller]")]
[ApiController]
public class ExecutionMessageController : ControllerBase
{
private readonly IExecutionMessageService _executionMessageService;
public ExecutionMessageController(IExecutionMessageService executionMessageService)
{
_executionMessageService = executionMessageService;
}
[HttpPost()]
[ProducesResponseType(typeof(List<ExecutionMessage>), 200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> Post([FromBody] List<ExecutionMessage> request)
{
try
{
if (request == null || !request.Any())
{
return BadRequest("Execution messages are required.");
}
await _executionMessageService.SaveExecutionMessages(request);
return Ok();
}
catch (ServiceException)
{
return StatusCode(StatusCodes.Status500InternalServerError);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}