Ejemplo n.º 1
0
        public static bool DeleteTask(List <Task> list)
        {
            Task selectedTask = GetSelectedTaskFromUser(list, "Enter task # to delete: ");

            UserInput.Display("Task to be deleted:\n\n");
            selectedTask.DisplayTask();
            if (UserInput.UserConfirmationPrompt("\nAre you sure(Y/N)? "))
            {
                return(list.Remove(selectedTask));
            }
            else
            {
                UserInput.Display("\nDelete cancelled!\n\n");
            }
            return(false);
        }
Ejemplo n.º 2
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);
        }