41 lines
1.3 KiB
C#
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);
|
|
}
|
|
}
|
|
} |