private void Purchase(String s) { if (Int32.TryParse(s, out int id)) { Console.Write(@" Enter quantity to purchase: "); s = Console.ReadLine(); if (Int32.TryParse(s, out int quantity)) { try { // this will just throw an error if the productID doesn't exist, to give a more accurate error message var product = c.GetProductNameByID(id); c.BuyProduct(currentStoreID, id, quantity); Console.WriteLine($"You bought {quantity} of {product}!"); } catch (Exception e) { Console.WriteLine(e.Message); } } else if (s == "" || s == "\n") { return; } } else if (s == "" || s == "\n") { return; } }