/// <summary> /// Updates the quantity for the given wine. Tracks the user who made the change as well. /// </summary> /// <param name="wineId">Wine to update.</param> /// <param name="quantity">Quantity to change to.</param> /// <param name="userId">User who made the change.</param> public static void UpdateInventory(int wineId, int quantity, int userId) { if (!UserTable.ContainsUserId(userId)) { throw new ArgumentException($"UpdateInventory({wineId}, {quantity}, {userId}*): UserId* does not exist, not performing quantity change"); } int oldQuantity = GetQuantity(wineId); int change = quantity - oldQuantity; tableManager.InventoryChangeTableAdapter.Insert(userId, wineId, change, DateTime.UtcNow); tableManager.InventoryTableAdapter.UpdateInventory(wineId, quantity); }