40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using LCU.Api.Internal.Dispatcher.Services;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Collections.Generic;
|
|
|
|
namespace LCU.Api.Internal.Dispatcher.Controllers;
|
|
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class WorkItemController : ControllerBase
|
|
{
|
|
private readonly IWorkItemService _workItemService;
|
|
|
|
public WorkItemController(IWorkItemService workItemService)
|
|
{
|
|
_workItemService = workItemService;
|
|
}
|
|
|
|
[HttpPost("GetWorkItemsByJobId")]
|
|
[ProducesResponseType(typeof(IEnumerable<WorkItem>), 200)]
|
|
[ProducesResponseType(500)]
|
|
public async Task<IActionResult> GetWorkItemsByJobId(int jobId)
|
|
{
|
|
try
|
|
{
|
|
var result = await _workItemService.GetByJobIdWithExecutionsAsync(jobId);
|
|
return Ok(result);
|
|
}
|
|
catch (ServiceException)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
Log.Error(exception, "Unexpected Exception");
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
}
|
|
}
|
|
}
|