Template Response
This commit is contained in:
@@ -42,13 +42,7 @@ namespace PARR.API.Controllers.V1
|
||||
{
|
||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||
|
||||
IQueryable<Template> query = templateService.Get()
|
||||
.Include(h => h.Host)
|
||||
.Include(a => a.ApplicationsInWork)
|
||||
.ThenInclude(w => w!.Work)
|
||||
.ThenInclude(t => t!.Tnk)
|
||||
.ThenInclude(s => s!.Subprocess)
|
||||
.ThenInclude(p => p!.Process)
|
||||
IQueryable<Template> query = templateService.GetWithIncludes()
|
||||
.OrderBy(t => t.Name)
|
||||
.AsSplitQuery();
|
||||
|
||||
@@ -89,7 +83,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpGet(ApiRoutes.Template.Get)]
|
||||
public async Task<IActionResult> GetById([FromRoute] Guid id)
|
||||
{
|
||||
var template = await templateService.GetAsync(id);
|
||||
var template = await templateService.GetWithIncludes()
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
if (template == null)
|
||||
return NotFound();
|
||||
@@ -107,7 +103,11 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpGet(ApiRoutes.Template.GetByStatusCode)]
|
||||
public async Task<IActionResult> GetByStatus([FromRoute] int statusCode, [FromQuery] RobinQuery query)
|
||||
{
|
||||
var template = await templateService.Get().FirstOrDefaultAsync(t => t.StatusCode == statusCode);
|
||||
//Тут узкое место, так как возвращается первый, елси будет много роботов, то будет возвращаться им один и тот же элемент.
|
||||
//нужно вводить статус, что эл уже занят
|
||||
var template = await templateService.GetWithIncludes()
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(t => t.StatusCode == statusCode);
|
||||
|
||||
if (template == null)
|
||||
return NotFound();
|
||||
@@ -132,7 +132,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPut(ApiRoutes.Template.SetOkStatus)]
|
||||
public async Task<IActionResult> SetOkStatus([FromRoute] Guid id)
|
||||
{
|
||||
var template = await templateService.GetAsync(id);
|
||||
var template = await templateService.GetWithIncludes()
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
if (template == null)
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Не найден шаблон с id: {id}" } }));
|
||||
|
||||
Reference in New Issue
Block a user