private static void removePurchase(ShoppingList MainList) { long number; Console.WriteLine("Enter a number in list of purchase you want to delete"); while (!long.TryParse(Console.ReadLine(), out number)) { Console.WriteLine("Looks like you misstaped some keys. Try to input INTEGER one more time"); } switch (MainList.RemovePurchase(number)) { case Status.OK: Console.WriteLine("Purchase note was successfully deleted\n"); break; case Status.Failed: Console.WriteLine("An error has occured. Possible, note that you want to delete doesn't exist?\n"); break; } }
private static void addPurchase(ShoppingList MainList) { string name; string comment; double spentamount; DateTime dateofpurchase; Console.WriteLine("Enter name of purchase"); name = Console.ReadLine(); Console.WriteLine("Enter comment for purchase"); comment = Console.ReadLine(); Console.WriteLine("Enter amount of spent credit"); while (!double.TryParse(Console.ReadLine(), out spentamount)) { Console.WriteLine("Look's like you've made a mistake. Try one more time"); } Console.WriteLine("Enter date of purchase in format dd MM yyyy"); while (!DateTime.TryParseExact(Console.ReadLine(), "dd MM yyyy", new CultureInfo("ru-Ru"), DateTimeStyles.None, out dateofpurchase)) { Console.WriteLine("Something went wrong. Try to input one more time"); } switch (MainList.AddPurchase(name, comment, spentamount, dateofpurchase)) { case Status.OK: Console.WriteLine("Purchase was successfully added\n"); break; case Status.Unexpected: Console.WriteLine("Some of your inputed data quite suspision. Are you sure that everything alright?\n"); break; } }