예제 #1
0
        /// <summary>
        /// The method that is called
        /// if the user is an admin.
        /// </summary>
        private static void AdminTools()
        {
            SharedMethod shared = new SharedMethod();
            List<string> bannedList = shared.PrintBannedList();
            int selectedOption;

            PrintBannedList(bannedList);

            Console.WriteLine("\r\n1 - Add word(s) to list");
            Console.WriteLine("2 - Remove word(s) from list");
            Console.WriteLine("3 - Clear list");
            Console.WriteLine("Please select an option from the above.");
            bool validOption = int.TryParse(Console.ReadLine(), out selectedOption);

            if (validOption == false || selectedOption > 3 || selectedOption < 1)
            {
                Console.WriteLine("You have selected an invalid option, press ANY key to try again.");
                Console.ReadLine();
                Program.AdminTools();
            }

            if (selectedOption == 1)
            {
                Console.WriteLine("Please type the words to add to the list as comma seperated values.");

                List<string> wordsToAdd = new List<string>();
                wordsToAdd.AddRange(Console.ReadLine().Split(','));

                shared.AddWordsToBannedList(wordsToAdd);
                PrintBannedList(bannedList);
            }
            else if (selectedOption == 2)
            {
                Console.WriteLine("Please type the words to remove from the list as comma seperated values.");

                List<string> wordsToRemove = new List<string>();
                wordsToRemove.AddRange(Console.ReadLine().Split(','));

                shared.RemoveWordsFromBannedList(wordsToRemove);
                PrintBannedList(bannedList);
            }
            else if (selectedOption == 3)
            {
                Console.WriteLine(shared.ClearBannedList());
            }
        }