private static void Add() { Console.Clear(); Console.WriteLine("Add menu: \n"); Console.WriteLine("1. Add new person"); Console.WriteLine("2. Add new medal"); Console.WriteLine("3. Add new reward"); Console.WriteLine("4. To main menu"); Console.Write("\nChoose menu item "); switch (Console.ReadKey().Key) { case ConsoleKey.D1: { Console.WriteLine("\n"); Console.Write("Enter person's name: "); string name = Console.ReadLine(); Console.Write("Enter person's surname: "); string surname = Console.ReadLine(); Console.Write("Enter person's date of birth: "); DateTime dateOfBirth = DateTime.Parse(Console.ReadLine()); Console.Write("Enter person's age: "); int age = int.Parse(Console.ReadLine()); Console.Write("Enter city of residence: "); string city = Console.ReadLine(); Console.Write("Enter street's name: "); string street = Console.ReadLine(); Console.Write("Enter house number: "); string houseNumber = Console.ReadLine(); try { personLogic.Add(name, surname, dateOfBirth, age, city, street, houseNumber); //personLogic.Add("Ivan", "Ivanov", new DateTime(1996, 12, 27), 30, "Saratov", "Chapaeva", "47a"); } catch (ArgumentNullException nullEx) { Console.WriteLine($"\n{nullEx.Message}"); Console.WriteLine("Press any key for continue"); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine($"\n{ex.Message}"); Console.WriteLine("Press any key for continue"); Console.ReadKey(); } Start(); break; } case ConsoleKey.D2: { Console.WriteLine("\n"); Console.Write("Enter medal's title: "); string title = Console.ReadLine(); Console.Write("Enter medal's material: "); string material = Console.ReadLine(); try { medalLogic.Add(title, material); //medalLogic.Add("For summer practice", null); } catch (ArgumentNullException nullEx) { Console.WriteLine($"\n{nullEx.Message} \n "); Console.WriteLine("Press any key for continue"); Console.ReadKey(); } Start(); break; } case ConsoleKey.D3: { Console.WriteLine("\n"); Console.Write("Enter person's ID: "); int personID = int.Parse(Console.ReadLine()); Console.Write("Enter meadl's ID: "); int medalID = int.Parse(Console.ReadLine()); try { personLogic.AddReward(personID, medalID); //personLogic.Add(1, 1); } catch (ArgumentNullException nullEx) { Console.WriteLine($"\n{nullEx.Message} \n "); Console.WriteLine("Press any key for continue"); Console.ReadKey(); } Start(); break; } case ConsoleKey.D4: { Start(); break; } default: return; } }
public void TestAddingReward() { logic.AddReward(1, 1); }