// The transaction is handled here public void Receipt(string username, int productID, int quantity) { User user; Product product; // Checks whether a username as the given, exists if (_stregsystem.GetUserByUsername(username) != null) { user = _stregsystem.GetUserByUsername(username); // Checks whether a product ID as the given, exists if (_stregsystem.GetProductByID(productID) != null) { product = _stregsystem.GetProductByID(productID); // Checks whether the product is active if (product.Active) { // Checks if the user can afford the product and the quantity of it, and if not, if the product can be bought on credit if (product.Price * quantity <= user.Balance || product.CanBeBoughtOnCredit) { BuyTransaction purchase = null; for (int i = 0; i < quantity; i++) { purchase = _stregsystem.BuyProduct(user, product); } ConsoleReceipt receipt = new ConsoleReceipt(purchase, quantity, false); receipt.Print(); } else { _ui.DisplayInsufficientCash(user, product); } } else { _ui.DisplayProductNotActive($"{product.ID}"); } } else { _ui.DisplayProductNotFound(); } } else { _ui.DisplayUserNotFound(username); } }