Ejemplo n.º 1
0
        private static void Menu()
        {
            Logger.AddLine("Called");

            #region menu

            Console.Clear();
            Console.WriteLine("Please select one of the following options");
            Console.WriteLine("e : Exit the application");
            if (Vars.AdminKey != null)
            {
                Console.WriteLine("c : Save the list and close the server");
                Console.WriteLine("s : Save the list to servers disk");
                Console.WriteLine("cl: Clear the list on the server");
            }

            Console.WriteLine("1 : Read Current list");
            Console.WriteLine("2 : Search in list");
            Console.WriteLine("3 : Sort list");
            if (Vars.EditKey != null || Vars.AdminKey != null)
            {
                Console.WriteLine("4 : Add a new article");
                Console.WriteLine("5 : Delete a article");
            }

            Console.WriteLine("");
            Console.Write("Your input: ");
            var input = Console.ReadLine()?.ToLower();

            #endregion

            #region menuInputHandler

            if (input == "1")
            {
                Functions.LocalFunctions.UserFunctions.ReadList();
            }
            else if (input == "2")
            {
                Functions.LocalFunctions.UserFunctions.SearchList();
            }
            else if (input == "3")
            {
                Functions.LocalFunctions.UserFunctions.SortList();
            }
            else if (input == "4")
            {
                if (Vars.EditKey != null || Vars.AdminKey != null)
                {
                    Editfunctions.AddArticle();
                }
            }
            else if (input == "5")
            {
                if (Vars.EditKey != null || Vars.AdminKey != null)
                {
                    Editfunctions.RemoveArticle();
                }
            }
            else if (input == "e")
            {
                Environment.Exit(0xDEAD);
            }
            else if (input == "c")
            {
                if (Vars.AdminKey != null)
                {
                    AdminFunctions.CloseServer();
                }
            }
            else if (input == "s")
            {
                if (Vars.AdminKey != null)
                {
                    AdminFunctions.SaveList();
                }
            }
            else if (input == "cl")
            {
                if (Vars.AdminKey != null)
                {
                    AdminFunctions.ClearList();
                }
            }

            #endregion
        }