This commit is contained in:
@@ -286,6 +286,41 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get on hand inventory values in all warehouses for part id specified
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="partId"></param>
|
||||||
|
/// <returns>Array of part on hand inventory levels by warehouse</returns>
|
||||||
|
[HttpGet("on-hand-inventory/{partId}")]
|
||||||
|
public async Task<IActionResult> GetPartOnHandInventory([FromRoute] long partId)
|
||||||
|
{
|
||||||
|
if (!serverState.IsOpen)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
|
||||||
|
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.PartInventory))
|
||||||
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
|
||||||
|
//get all warehouses
|
||||||
|
var allWhs=await ct.PartWarehouse.AsNoTracking().ToListAsync();
|
||||||
|
|
||||||
|
//iterate them and compile the last inventory for each warehouse for this part
|
||||||
|
foreach(PartWarehouse pw in allWhs){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var LastEntry = await ct.PartInventory.OrderByDescending(m => m.EntryDate).FirstOrDefaultAsync(m => m.PartId == newDtObject.PartId && m.PartWarehouseId == newDtObject.PartWarehouseId);
|
||||||
|
var o = await ct.PartStockLevel.AsNoTracking().Where(z => z.PartId == partId).OrderBy(z => z.PartWarehouseId).ToListAsync();
|
||||||
|
foreach (PartStockLevel ps in o)
|
||||||
|
{
|
||||||
|
ps.PartWarehouseDisplay = await ct.PartWarehouse.AsNoTracking().Where(z => z.Id == ps.PartWarehouseId).Select(z => z.Name).FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(ApiOkResponse.Response(o));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//------------
|
//------------
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user