feat(api): получит наряд по ИД
This commit is contained in:
@@ -217,6 +217,7 @@ namespace PARR.API.Contracts.V1
|
|||||||
public static class Order
|
public static class Order
|
||||||
{
|
{
|
||||||
public const string GetAll = Base + "/orders/";
|
public const string GetAll = Base + "/orders/";
|
||||||
|
public const string Get = Base + "/orders/" + getParam;
|
||||||
|
|
||||||
public const string getParam = "{id}";
|
public const string getParam = "{id}";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ namespace PARR.API.Controllers.V1
|
|||||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||||
|
|
||||||
var query = orderService.Get()
|
var query = orderService.Get()
|
||||||
.Include(t=>t.Template)
|
.Include(t => t.Template)
|
||||||
.Include(s=>s.OrderStatus)
|
.Include(s => s.OrderStatus)
|
||||||
.Include(s => s.NextStatus)
|
.Include(s => s.NextStatus)
|
||||||
.OrderByDescending(t => t.DateCreated);
|
.OrderByDescending(t => t.DateCreated);
|
||||||
|
|
||||||
@@ -60,5 +60,28 @@ namespace PARR.API.Controllers.V1
|
|||||||
return Ok(paginationResponse);
|
return Ok(paginationResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить наряд по id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet(ApiRoutes.Order.Get)]
|
||||||
|
public async Task<IActionResult> Get([FromRoute] Guid id)
|
||||||
|
{
|
||||||
|
var order = await orderService.Get()
|
||||||
|
.Include(t => t.Template)
|
||||||
|
.Include(s => s.OrderStatus)
|
||||||
|
.Include(s => s.NextStatus)
|
||||||
|
.FirstOrDefaultAsync(t => t.Id == id);
|
||||||
|
|
||||||
|
if (order == null)
|
||||||
|
return NotFound();
|
||||||
|
|
||||||
|
var response = mapper.Map<OrderResponse>(order);
|
||||||
|
|
||||||
|
return Ok(new Response<OrderResponse>(response, true));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user