Files
Partsource/PartSource/Controllers/InventoryController.cs
2020-04-12 20:52:03 -04:00

39 lines
1.2 KiB
C#

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
}
});
}
}
}