51 lines
1.7 KiB
C#
51 lines
1.7 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using LCU.Api.Internal.FileOperations.Extensions;
|
|
using LCU.Api.Internal.FileOperations.Services.QueueServices;
|
|
using LCU.Library.Internal.FileOperationsModels.Models;
|
|
using LCU.Library.Internal.ApiResponse.Models;
|
|
using LCU.Library.Internal.Exceptions;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Serilog;
|
|
|
|
namespace LCU.Api.Internal.FileOperations.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class IndexFileController : ControllerBase
|
|
{
|
|
private readonly IQueueFileOperationsService _queueFileOperationsService;
|
|
|
|
public IndexFileController(IQueueFileOperationsService queueFileOperationsService)
|
|
{
|
|
_queueFileOperationsService = queueFileOperationsService;
|
|
}
|
|
|
|
[HttpPost("QueueExtractIndexFileData")]
|
|
[ProducesResponseType(200)]
|
|
[ProducesResponseType(typeof(ReturnResponse), 400)]
|
|
[ProducesResponseType(500)]
|
|
public async Task<IActionResult> QueueExtractIndexFileData([FromBody] ExtractIndexFileDataRequest request)
|
|
{
|
|
try
|
|
{
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return BadRequest(ModelState.GetErrorMessages());
|
|
}
|
|
|
|
await _queueFileOperationsService.QueueFileOperations(request, FileOperationType.ExtractIndexFileData);
|
|
return Accepted();
|
|
}
|
|
catch (ServiceException exception)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, exception.Message);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
Log.Error(exception, "Unexpected Exception");
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
}
|
|
}
|
|
} |