コード例 #1
0
        static void Main(string[] args)
        {
            bool isRunning = true;

            var listManager = new ProgramLogic();

            do
            {
                string command;

                ConsoleEx.Write(ConsoleColor.Green, "Wpisz komendę: ");
                command = Console.ReadLine();

                switch (command)
                {
                case "add":
                    ConsoleEx.WriteLine(ConsoleColor.Yellow, "--- DODAWANIE ZADANIA ---");
                    ConsoleEx.WriteLine(ConsoleColor.Yellow, "--- ----------------- ---");

                    var desc = AskForString("Podaj nazwe zadania");

                    var isImportant  = AskForBool("Czy zadanie ma byc oznaczone jako wazne? (T/N): ");
                    var isAllDayTask = AskForBool("Czy zadanie ma byc calodniowe? (T/N): ");

                    DateTime from;
                    DateTime?to = null;

                    if (isAllDayTask)
                    {
                        from = AskForDate("Data zadania");
                    }
                    else
                    {
                        from = AskForDate("Data rozpoczecia zadania");
                        to   = AskForDate("Data zakonczenia zadania");
                    }

                    listManager.AddTask(desc, from, to, isImportant);
                    break;

                case "remove":
                    ConsoleEx.WriteLine(ConsoleColor.Yellow, "--- USUWANIE ZADANIA ---");
                    ConsoleEx.WriteLine(ConsoleColor.Yellow, "--- ---------------- ---");

                    if (listManager.TaskCount == 0)
                    {
                        ConsoleEx.WriteLine(ConsoleColor.Red, "Brak zadan!");
                        break;
                    }

                    int numberOfTask = AskForNumberOfTask("Podaj nr zadania", listManager.TaskCount);

                    listManager.RemoveTask(numberOfTask);
                    break;

                case "show":
                    listManager.ShowTasks();
                    break;

                case "save":
                    listManager.SaveTasks();
                    break;

                case "load":
                    listManager.LoadTasks();
                    break;

                case "exit":
                    isRunning = false;
                    break;

                default:
                    break;
                }
            } while (isRunning);
        }