Files
monorepo/LCU.API.Internal.DocumentIngestor/LCU.API.Internal.DocumentIngestor/Controllers/DocumentIngestorController.cs
T
2026-03-25 14:50:13 -05:00

41 lines
1.3 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Serilog;
using LCU.Library.Internal.Exceptions;
using LCU.Library.Internal.DocumentIngestorModels.Models;
using LCU.API.Internal.DocumentIngestor.Services.QueueServices;
namespace LCU.API.Internal.DocumentIngestor.Controllers;
[ApiController]
[Route("[controller]")]
public class DocumentIngestorController : ControllerBase
{
private readonly IQueueDocumentIngestorService _queueDocumentIngestorService;
public DocumentIngestorController(IQueueDocumentIngestorService queueDocumentIngestorService)
{
_queueDocumentIngestorService = queueDocumentIngestorService;
}
[HttpPost("QueueDocumentIngestor")]
[ProducesResponseType(202)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> QueueDocumentIngestor([FromBody] IngestorRequest request)
{
try
{
await _queueDocumentIngestorService.QueueDocumentIngestorRequest(request);
return Accepted();
}
catch (ServiceException exception)
{
return StatusCode(StatusCodes.Status500InternalServerError, exception.Message);
}
catch (Exception exception)
{
Log.Error(exception, "Unexpected Exception");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}