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;
            }
        }
Esempio n. 2
0
        private static void Show()
        {
            Console.Clear();
            Console.WriteLine("Show menu:\n" +
                              "1. Show all people\n" +
                              "2. Show all medals\n" +
                              "3. Show all rewards\n" +
                              "4. Show person by id\n" +
                              "5. Show medal by id\n" +
                              "6. Go to the beginning");

            switch (Console.ReadKey().Key)
            {
            case ConsoleKey.D1:
            {
                Console.WriteLine();
                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($"List is empty.");
                }
                Console.WriteLine("\nPress any key for continue.");
                Console.ReadKey();

                Start();
                break;
            }

            case ConsoleKey.D2:
            {
                Console.WriteLine();

                var list = medalLogic.GetAll();


                if (list.Count() > 0)
                {
                    foreach (var item in list)
                    {
                        Console.WriteLine($"{item.Id}: {item.Name} {item.Material}");
                    }
                }
                else
                {
                    Console.WriteLine($"List is empty.");
                }
                Console.WriteLine("\nPress any key for continue.");
                Console.ReadKey();

                Start();
                break;
            }

            case ConsoleKey.D3:
            {
                Console.WriteLine();

                var list = rewardLogic.GetAll();


                if (list.Count() > 0)
                {
                    foreach (var item in list)
                    {
                        Console.WriteLine(item);
                    }
                }
                else
                {
                    Console.WriteLine($"List is empty.");
                }
                Console.WriteLine("\nPress any key for continue.");
                Console.ReadKey();

                Start();
                break;
            }

            case ConsoleKey.D4:
            {
                Console.WriteLine();
                Console.Write("Id: ");

                var item = personLogic.GetById(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 was not found.");
                }
                Console.WriteLine("\nPress any key for continue.");
                Console.ReadKey();

                Start();
                break;
            }

            case ConsoleKey.D5:
            {
                Console.WriteLine();
                Console.Write("Id: ");

                var item = medalLogic.GetById(int.Parse(Console.ReadLine()));

                if (item != null)
                {
                    Console.WriteLine($"{item.Id}: {item.Name} {item.Material}");
                }
                else
                {
                    Console.WriteLine($"This medal was not found.");
                }
                Console.WriteLine("\nPress any key for continue");
                Console.ReadKey();

                Start();
                break;
            }

            case ConsoleKey.D6:
            {
                Start();
                break;
            }

            default:
            {
                Console.WriteLine("\n\nInvalid input. Try again.");
                Thread.Sleep(2500);
                Start();
                break;
            }
            }
        }