44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using System;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Serilog;
|
|
using LCU.Api.Internal.ArchiverApi.Services;
|
|
using LCU.Library.Internal.ArchiverApiModel.Models;
|
|
using LCU.Library.Internal.Exceptions;
|
|
namespace LCU.Api.Internal.ArchiverApi.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class QueueArchiverController : ControllerBase
|
|
{
|
|
private readonly IQueueArchiverService _queueArchiverService;
|
|
|
|
public QueueArchiverController(IQueueArchiverService queueArchiverService)
|
|
{
|
|
_queueArchiverService = queueArchiverService;
|
|
}
|
|
|
|
[HttpPost("QueueArchiver")]
|
|
public IActionResult QueueArchiver(ArchiveRequest archiveRequest)
|
|
{
|
|
try
|
|
{
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return BadRequest(ModelState.Values);
|
|
}
|
|
|
|
_queueArchiverService.QueueArchiver(archiveRequest);
|
|
return Ok();
|
|
}
|
|
catch (ServiceException)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
Log.Error(exception, "Unexpected Exception");
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
}
|
|
}
|
|
} |