Esempio n. 1
0
        //дейтсвия для Awards
        private static void AwardsAction()
        {
            while (true)
            {
                Console.WriteLine();
                Console.WriteLine($"1: Find award by ID");
                Console.WriteLine($"2: Find award by Name");
                Console.WriteLine($"3: Find award by the first letter");
                Console.WriteLine($"4: Find award whose name includes the entered word");
                Console.WriteLine($"5: Delete award");
                Console.WriteLine($"6: Edit award");
                Console.WriteLine($"7: EXIT");

                Console.Write("Choose action: ");

                var userEnter = Console.ReadLine();

                switch (userEnter)
                {
                case "1":
                    Console.Write($"Award's ID: ");
                    var id_1     = Console.ReadLine();
                    var result_1 = awardLogic.GetAwardById(id_1);
                    Console.WriteLine($"{result_1.IdAward} : {result_1.Title} : {result_1.Description}{Environment.NewLine}");
                    break;

                case "2":
                    Console.Write($"Award's Title: ");
                    var name_2 = Console.ReadLine();
                    foreach (var item in awardLogic.GetAwardByTitle(name_2))
                    {
                        Console.WriteLine($"{item.IdAward} : {item.Title} : {item.Description}{Environment.NewLine}");
                    }
                    break;

                case "3":
                    Console.Write($"Write letter: ");
                    var letter_3 = Console.ReadLine();
                    foreach (var item in awardLogic.GetAwardByLetter(letter_3))
                    {
                        Console.WriteLine($"{item.IdAward} : {item.Title} : {item.Description}{Environment.NewLine}");
                    }
                    break;

                case "4":
                    Console.Write($"Write word: ");
                    var word = Console.ReadLine();
                    foreach (var item in awardLogic.GetAwardByWord(word))
                    {
                        Console.WriteLine($"{item.IdAward} : {item.Title} : {item.Description}{Environment.NewLine}");
                    }
                    break;

                case "5":
                    Console.Write($"Award's ID: ");
                    var id_5 = Console.ReadLine();
                    awardLogic.DeleteAward(id_5);
                    break;

                case "6":
                    Console.Write($"award's ID: ");
                    var id_6     = Console.ReadLine();
                    var result_6 = awardLogic.GetAwardById(id_6);
                    Console.Write($"award's Titile: ");
                    var title = Console.ReadLine();
                    Console.Write($"award's Description: ");
                    var description = Console.ReadLine();
                    awardLogic.UpdateAward(id_6, title, description);
                    break;

                case "7":
                    return;

                default:
                    break;
                }
            }
        }