public void GetInventory(int locationid) { List <DataModel.Inventory> inventories = storeRepo.GetInventoryByLocationId(locationId); Console.WriteLine($"Product Id\t Product Name \t\t Price"); foreach (var inventory in inventories) { Console.WriteLine($"{inventory.ProductId}\t\t{inventory.Product.Name}\t\t{inventory.Product.Price}"); } }
// GET: /<controller>/ public IActionResult Index(int id) { if (id < 0) { return(NotFound()); } var inventory = _storeRepo.GetInventoryByLocationId(id); return(View(inventory)); }
public void GetInventory() { Console.WriteLine("Enter the Location's Id to view Inventory:"); locationId = Int32.Parse(Console.ReadLine()); List <DataModel.Inventory> inventories = storeRepo.GetInventoryByLocationId(locationId); Console.WriteLine($"Product Id\t Product Name \t\t Price \t\t Quantity In Stock"); foreach (var inventory in inventories) { Console.WriteLine($"{inventory.ProductId}\t\t{inventory.Product.Name}\t\t{inventory.Product.Price}\t\t\t{inventory.Quantity}"); } }
public ActionResult AddItem(Library.OrderDetail item) { if (ModelState.IsValid) { var order = _storeRepo.GetOrderById(item.OrderId); var inventory = _storeRepo.GetInventoryByLocationId(order.LocationId); var product = inventory.Find(o => o.ProductId == item.ProductId); if (product.Quantity - item.Quantity < 0) { return(RedirectToAction(nameof(AddItem), new { id = item.OrderId })); } if (order.OrderDetails.Any(o => o.ProductId == item.ProductId)) { foreach (var entry in order.OrderDetails) { if (entry.ProductId == item.ProductId) { entry.Quantity += item.Quantity; _storeRepo.UpdateOrderDetail(entry); return(RedirectToAction(nameof(Details), new { id = item.OrderId })); } } ; } else { _storeRepo.AddOrderItem(item); } product.Quantity -= item.Quantity; _storeRepo.UpdateInventory(product.LocationId, product.ProductId, product.Quantity); return(RedirectToAction(nameof(Details), new { id = item.OrderId })); } return(View("Index")); }