Exemplo n.º 1
0
        /// <summary>
        /// Menu for medicines
        /// </summary>
        public static void Choice()
        {
            ConsoleEx.WriteLine("Avaiable commands for Medicines:\n1. Show all (show)\n2. Add medicine (add)\n3. Edit medicine (edit)\n4. Remove medicine (rem)\n5. Go to previous menu (exit)", ConsoleColor.Yellow);
            Medicine med    = new Medicine();
            string   choice = Console.ReadLine();

            if (choice == "1" || choice.ToLower() == "show")
            {
                Console.Clear();
                med.ShowAll();
            }
            else if (choice == "2" || choice.ToLower() == "add")
            {
                Console.Clear();
                med.Save();
            }
            else if (choice == "3" || choice == "edit")
            {
                Console.Clear();
                Console.Write("Write Medicine's ID to ");
                ConsoleEx.Write("Edit: ", ConsoleColor.Cyan);
                int id = Int32.Parse(Console.ReadLine());
                med.Reload(id);
            }
            else if (choice == "4" || choice.ToLower() == "remove")
            {
                Console.Clear();
                Console.Write("Write Medicine's ID to ");
                ConsoleEx.Write("Remove: ", ConsoleColor.Red);
                int id = Int32.Parse(Console.ReadLine());
                med.Remove(id);
            }
            else if (choice == "5" || choice.ToLower() == "exit")
            {
                Console.Clear();
                return;
            }
        }