public void TestAdding() { int id = logic.Add("For test", "Bronze"); var medal = new Medal { Title = "For test", Material = "Bronze" }; Assert.AreEqual(Medal.ToString(logic.ShowById(id)), Medal.ToString(medal), "Adding data about person incorrect"); logic.Delete(id); }
private static void Show() { Console.Clear(); Console.WriteLine("Show menu: \n"); Console.WriteLine("1. Show all people"); Console.WriteLine("2. Show all medals"); Console.WriteLine("3. Show all rewards"); Console.WriteLine("4. Show person by ID"); Console.WriteLine("5. Show medal by ID"); Console.WriteLine("6. To main menu"); Console.Write("\nChoose menu item "); switch (Console.ReadKey().Key) { case ConsoleKey.D1: { Console.WriteLine("\n"); var list = personLogic.GetAll(); if (list.Count() > 0) { foreach (var item in list) { Console.WriteLine($"{item.Id}: {item.Name} {item.Surname} {item.Age} {item.DateOfBirth} {item.City} {item.Street} {item.NumberOfHouse}"); } } else { Console.WriteLine($"This table is empty"); } Console.WriteLine("\nPress any key for continue"); Console.ReadKey(); Start(); break; } case ConsoleKey.D2: { Console.WriteLine("\n"); var list = medalLogic.GetAll(); if (list.Count() > 0) { foreach (var item in list) { Console.WriteLine($"{item.Id}: {item.Title} {item.Material}"); } } else { Console.WriteLine($"This table is empty"); } Console.WriteLine("\nPress any key for continue"); Console.ReadKey(); Start(); break; } case ConsoleKey.D3: { Console.WriteLine("\n"); var list = personLogic.GetAllRewards(); if (list.Count() > 0) { foreach (var item in list) { Console.WriteLine(item); } } else { Console.WriteLine($"This table is empty"); } Console.WriteLine("\nPress any key for continue"); Console.ReadKey(); Start(); break; } case ConsoleKey.D4: { Console.WriteLine("\n"); Console.Write("Enter person's ID: "); var item = personLogic.ShowById(int.Parse(Console.ReadLine())); if (item != null) { Console.WriteLine($"{item.Id}: {item.Name} {item.Surname} {item.Age} {item.DateOfBirth} {item.City} {item.Street} {item.NumberOfHouse}"); } else { Console.WriteLine($"This person wasn't create or was deleted"); } Console.WriteLine("\nPress any key for continue"); Console.ReadKey(); Start(); break; } case ConsoleKey.D5: { Console.WriteLine("\n"); Console.Write("Enter medal's ID: "); var item = medalLogic.ShowById(int.Parse(Console.ReadLine())); if (item != null) { Console.WriteLine($"{item.Id}: {item.Title} {item.Material}"); } else { Console.WriteLine($"This person wasn't create or was deleted"); } Console.WriteLine("\nPress any key for continue"); Console.ReadKey(); Start(); break; } case ConsoleKey.D6: { Start(); break; } default: return; } }