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), 200)] [ProducesResponseType(400)] [ProducesResponseType(500)] public async Task Post([FromBody] List 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); } } }