Ejemplo n.º 1
0
        private static bool PerformAdvancedTask(int selectedOption, List <Task> taskList)
        {
            if (selectedOption == 1)
            {
                DisplayTasksByOwnerName(taskList);
            }
            else if (selectedOption == 2)
            {
                DisplayAllTaskBeforeDate(taskList);
            }
            else if (selectedOption == 3)
            {
                try
                {
                    Task selectedTask = GetSelectedTaskFromUser(taskList,
                                                                "Enter Task# to edit: ");

                    selectedTask.DisplayTask();

                    if (UserInput.UserConfirmationPrompt("Are you sure(Y/N)"))
                    {
                        selectedTask = Task.AddOrEdit(selectedTask, true);
                        UserInput.Display("Updated!");
                    }
                    else
                    {
                        UserInput.Display("Cancelled by user.");
                    }
                }
                catch (Exception)
                {
                    UserInput.Display("Item does not exists!");
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            List <Task> taskList = new List <Task>();
            bool        repeat   = true;

            taskList = TestData();

            while (repeat)
            {
                try
                {
                    switch (GetInputFromMainMenu())
                    {
                    case 1:
                        Console.Clear();
                        DisplayAllTasks(taskList);
                        Pause();

                        break;

                    case 2:
                        taskList.Add(Task.AddOrEdit(null));
                        UserInput.Display("New task added!");
                        Pause();

                        break;

                    case 3:
                        if (DeleteTask(taskList))
                        {
                            UserInput.Display("\nDeleted!\n\n");
                        }
                        Pause();

                        break;

                    case 4:
                        MarkTaskAsComplete(taskList);
                        Pause();

                        break;

                    case 5:
                        Console.Clear();
                        while (repeat)
                        {
                            int selectedOption = AdvancedOptionMenu();
                            //if user exit advanced option repeat equals false
                            repeat = PerformAdvancedTask(selectedOption, taskList);
                            if (repeat)
                            {
                                Pause();
                            }
                        }
                        repeat = true;    //Set back to true for main menu


                        break;

                    case 6:
                        if (UserInput.UserConfirmationPrompt("Are you sure(Y/N)?"))
                        {
                            repeat = false;
                        }
                        break;

                    default:
                        break;
                    }
                }
                catch (ArgumentOutOfRangeException)
                {
                    UserInput.Display("That record does not exists. " +
                                      "Use option 1 to view the list of tasks");
                }
            }//while
            UserInput.Display("Goodbye!\n");
        }