public void Purchase(string productId, int quantity) { Product product = this.GetProductById(productId); if (!UserHasFundsForPurchase(product, quantity)) { throw new InsufficientFundsException(); } if (!StoreHasStockForPurchase(product, quantity)) { throw new OutOfStockException(); } product.Quantity = product.Quantity - quantity; user.Balance = user.Balance - product.Price * quantity; dataManager.SaveUser(user); dataManager.SaveProduct(product); }