Initial commit
This commit is contained in:
38
PartSource/Controllers/InventoryController.cs
Normal file
38
PartSource/Controllers/InventoryController.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using PartSource.Entities.Models;
|
||||
using PartSource.Services;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace PartSource.Controllers
|
||||
{
|
||||
[RoutePrefix("inventory")]
|
||||
public class InventoryController : BaseNexpartController
|
||||
{
|
||||
private readonly InventoryService _inventoryService;
|
||||
|
||||
public InventoryController(InventoryService inventoryService)
|
||||
{
|
||||
_inventoryService = inventoryService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("sku/{sku}/storeNumber/{storeNumber}")]
|
||||
public async Task<IHttpActionResult> GetInventory(int sku, int storeNumber)
|
||||
{
|
||||
ps_parts_availability inventory = _inventoryService.GetInventory(sku, storeNumber);
|
||||
|
||||
return inventory == null
|
||||
? Content(HttpStatusCode.NotFound, $"No part matching SKU {sku} was found.")
|
||||
: (IHttpActionResult)Ok(new
|
||||
{
|
||||
data = new
|
||||
{
|
||||
StoreNumber = inventory.Store,
|
||||
Sku = sku,
|
||||
Quantity = inventory.QTY
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user