// TODO: add docs public ProductInventory UpdateLocationInventory(Location location, Product product, int quantity) { ProductInventory productInventory; using (var ctx = new VendorContext()) { ProductInventorieService pIS = new ProductInventorieService(ctx); productInventory = pIS.UpdateInventory(location, product, quantity); } return(productInventory); }
// Add/Restock a Product(s) to this location public void AddProductToInventory(int locationId, int productId, int quantity = 1) { // Fetch the location and the product to add to location Product prod = ctx.Products.Find(productId); // * Find ProductInventoryRecord // Location loc = ctx.Locations.Include(l => l.ProductInventoryRecords).FirstOrDefault(l => l.LocationId == locationId); Location loc = ctx.Locations.Find(locationId); // Add inventory record for location ProductInventorieService pIS = new ProductInventorieService(ctx); pIS.Create(loc, prod, quantity); }