using System.Collections.Generic; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using LCU.Api.Internal.Dispatcher.Extensions; using LCU.Api.Internal.Dispatcher.Services.QueueServices; namespace LCU.Api.Internal.Dispatcher.Controllers; [Route("api/[controller]")] [ApiController] public class QueueExecutionController : ControllerBase { private readonly IQueueExecutionService _queueExecutionService; public QueueExecutionController(IQueueExecutionService executionService) { _queueExecutionService = executionService; } [HttpPost("QueueRetryExecution")] [ProducesResponseType(202)] [ProducesResponseType(typeof(List), 400)] [ProducesResponseType(500)] public async Task QueueRetryExecutionController([FromBody] WorkItemExecution request) { try { if (!ModelState.IsValid) { return BadRequest(ModelState.GetErrorMessages()); } await _queueExecutionService.QueueRetryExecution(request); return Accepted(); } catch (ServiceException) { return StatusCode(StatusCodes.Status500InternalServerError); } catch (Exception exception) { Log.Error(exception, "Unexpected Exception"); return StatusCode(StatusCodes.Status500InternalServerError); } } }