Adding
This commit is contained in:
+51
@@ -0,0 +1,51 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using LCU.Api.Internal.Dispatcher.Extensions;
|
||||
using LCU.Api.Internal.Dispatcher.Services.DispatcherOperationServices;
|
||||
namespace LCU.Api.Internal.Dispatcher.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class IngestionController : ControllerBase
|
||||
{
|
||||
private readonly IIngestionService _ingestionService;
|
||||
|
||||
public IngestionController(IIngestionService ingestionService)
|
||||
{
|
||||
_ingestionService = ingestionService;
|
||||
}
|
||||
|
||||
// POST api/Post
|
||||
[HttpPost]
|
||||
[ProducesResponseType(201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Post([FromBody] Job request)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
if (!request.WorkItems.Any())
|
||||
{
|
||||
return BadRequest("Workitems are required.");
|
||||
}
|
||||
|
||||
await _ingestionService.HandleIngestionRequest(request);
|
||||
return Ok();
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user