private void DisplayToDoTaskDetails() { bool inTaskDetails = true; while (inTaskDetails) { Console.Clear(); Console.WriteLine($"Name: {ToDoApp.SelectedToDoTask.Name}"); Console.WriteLine($"Description: {ToDoApp.SelectedToDoTask.Description}"); Console.WriteLine(); Console.WriteLine("[1] Edit Task"); Console.WriteLine("[2] Remove Task"); Console.WriteLine($"[Q] Return to {ToDoApp.SelectedTaskList.Name} Task List"); Console.WriteLine(); int selection = NavigationTools.SelectSingleIntegerOrQ(1, 2); if (selection == -1) { inTaskDetails = false; DisplayToDoTasks(); } else if (selection == 1) { inTaskDetails = false; EditToDoTask(); } else if (selection == 2) { Console.WriteLine(); bool removeTask = NavigationTools.GetBoolYorN($"Are you sure you want permanently remove {ToDoApp.SelectedToDoTask.Name}? [Y/N]: "); if (removeTask) { inTaskDetails = false; ToDoApp.RemoveTask(ToDoApp.SelectedToDoTask.Id); DisplayToDoTasks(); } } } }
private void DisplayAddToDoTaskView() { bool inAddToDoTaskView = true; ToDoTask task = new ToDoTask() { ListId = ToDoApp.SelectedTaskList.Id, Name = String.Empty, Description = String.Empty }; while (inAddToDoTaskView) { Console.Clear(); Console.WriteLine("Practice ToDo Console App: Creating a New ToDo Task"); Console.WriteLine(); Console.WriteLine($"Name: {task.Name}"); Console.WriteLine($"Description: {task.Description}"); Console.WriteLine(); Console.WriteLine("[1] Add a Name"); Console.WriteLine("[2] Add a Description"); Console.WriteLine("[3] Save ToDo Task"); Console.WriteLine($"[Q] Cancel and Return to {ToDoApp.SelectedTaskList.Name}'s Details page"); int selection = NavigationTools.SelectSingleIntegerOrQ(1, 3); if (selection == -1) { inAddToDoTaskView = false; DisplayTaskListDetails(); } else if (selection == 1) { Console.WriteLine(); task.Name = NavigationTools.SelectString("Enter a Name: "); } else if (selection == 2) { Console.WriteLine(); task.Description = NavigationTools.SelectString("Enter a Description: "); } else if (selection == 3) { bool saveTaskList = false; Console.WriteLine(); Console.WriteLine(); if (!String.IsNullOrEmpty(task.Name)) { if (!String.IsNullOrEmpty(task.Description)) { saveTaskList = NavigationTools.GetBoolYorN("Are you sure you want save these changes? [Y/N]: "); } else { Console.WriteLine("Please add a Description to your ToDo Task before saving"); } } else if (String.IsNullOrEmpty(task.Description) && String.IsNullOrEmpty(task.Name)) { Console.WriteLine("Please add a Name and a Description to your ToDo Task before saving"); } else { Console.WriteLine("Please add a Name to your ToDo Task before saving"); } if (saveTaskList) { ToDoApp.AddNewTask(task); inAddToDoTaskView = false; DisplayTaskListDetails(); } else { Console.WriteLine(); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); } } } }
public void DisplaySettings() { bool inDisplaySettings = true; int? taskListsPerPage = null; int? toDoTasksPerPage = null; bool?changeCategoryView = null; while (inDisplaySettings) { Console.Clear(); Console.WriteLine("Practice ToDo Console App: Settings"); Console.WriteLine(); Console.WriteLine($"Number of Task Lists per page: {NumberOfTaskListstoDisplayPerPage} (Default: 10)"); Console.WriteLine($"Number of ToDo Tasks per page: {NumberOfToDoTasksToDisplayPerPage} (Default: 10)"); Console.WriteLine($"Task List Category View Enabled: {CategoryView}"); Console.WriteLine(); if (taskListsPerPage != null) { Console.WriteLine($"New number of Task Lists per page: {taskListsPerPage}"); } if (toDoTasksPerPage != null) { Console.WriteLine($"New number of ToDo Tasks per page: {toDoTasksPerPage}"); } if (changeCategoryView != null) { Console.WriteLine($"Updated Task List Category View Enabled: {changeCategoryView}"); } Console.WriteLine(); Console.WriteLine("[1] Change Number of Task Lists"); Console.WriteLine("[2] Change Number of ToDo Tasks"); Console.WriteLine("[3] Toggle Task List Category View"); Console.WriteLine("[4] Save Changes"); Console.WriteLine("[Q] Return to Main Menu"); int selection = NavigationTools.SelectSingleIntegerOrQ(1, 4); if (selection == -1) { inDisplaySettings = false; MainMenu(); } else if (selection == 1) { Console.Clear(); Console.WriteLine($"Current number of Task Lists per page: {NumberOfTaskListstoDisplayPerPage}"); Console.WriteLine(); taskListsPerPage = NavigationTools.SelectInteger("Input a value between 1 and 50: ", 1, 50); } else if (selection == 2) { Console.Clear(); Console.WriteLine($"Current number of ToDo Tasks per page: {NumberOfToDoTasksToDisplayPerPage}"); Console.WriteLine(); toDoTasksPerPage = NavigationTools.SelectInteger("Input a value between 1 and 50: ", 1, 50); } else if (selection == 3) { Console.Clear(); Console.WriteLine(); changeCategoryView = NavigationTools.GetBoolYorN("[Y] To enable Category View \n[N] To disable Category View\n[Y]/[N]: "); } else if (selection == 4) { Console.Clear(); Console.WriteLine(); Console.WriteLine($"Current number of Task Lists per page: {NumberOfTaskListstoDisplayPerPage}"); Console.WriteLine($"Current number of ToDo Tasks per page: {NumberOfToDoTasksToDisplayPerPage}"); Console.WriteLine(); Console.WriteLine("To..."); Console.WriteLine(); if (taskListsPerPage != null) { Console.WriteLine($"New number of Task Lists per page: {taskListsPerPage}"); } if (toDoTasksPerPage != null) { Console.WriteLine($"New number of ToDo Tasks per page: {toDoTasksPerPage}"); } if (changeCategoryView != null) { Console.WriteLine($"Updated Task List Category View Enabled: {changeCategoryView}"); } Console.WriteLine(); bool shouldSave = NavigationTools.GetBoolYorN("Are you sure you want save these settings? [Y]/[N]: "); if (shouldSave) { if (taskListsPerPage != null) { NumberOfTaskListstoDisplayPerPage = (int)taskListsPerPage; taskListsPerPage = null; } if (taskListsPerPage != null) { NumberOfToDoTasksToDisplayPerPage = (int)toDoTasksPerPage; toDoTasksPerPage = null; } if (changeCategoryView != null) { CategoryView = (bool)changeCategoryView; changeCategoryView = null; } } } } }
private void EditToDoTask() { bool inEditTask = true; string name = String.Empty; string desc = String.Empty; ToDoTask task = new ToDoTask() { Id = ToDoApp.SelectedToDoTask.Id, ListId = ToDoApp.SelectedToDoTask.ListId }; while (inEditTask) { Console.Clear(); Console.WriteLine($"Name: {ToDoApp.SelectedToDoTask.Name}"); Console.WriteLine($"Description: {ToDoApp.SelectedToDoTask.Description}"); Console.WriteLine(); if (!String.IsNullOrEmpty(name)) { Console.WriteLine($"New Name: {name}"); } if (!String.IsNullOrEmpty(desc)) { Console.WriteLine($"New Description: {desc}"); } if (!String.IsNullOrEmpty(name) || !String.IsNullOrEmpty(desc)) { Console.WriteLine(); } Console.WriteLine("[1] Change Name"); Console.WriteLine("[2] Change Description"); Console.WriteLine("[3] Save your changes"); Console.WriteLine($"[Q] Return to {ToDoApp.SelectedTaskList.Name} Tasks"); int selection = NavigationTools.SelectSingleIntegerOrQ(1, 3); if (selection == -1) { inEditTask = false; DisplayToDoTasks(); } else if (selection == 1) { Console.WriteLine(); name = NavigationTools.SelectString("Please enter a new name: "); task.Name = name; } else if (selection == 2) { Console.WriteLine(); desc = NavigationTools.SelectString("Please enter a new description: "); task.Description = desc; } else if (selection == 3) { Console.Clear(); Console.WriteLine($"Name: {ToDoApp.SelectedTaskList.Name}"); Console.WriteLine($"Description: {ToDoApp.SelectedTaskList.Description}"); Console.WriteLine(); Console.WriteLine("To..."); Console.WriteLine(); Console.WriteLine($"Name: {task.Name}"); Console.WriteLine($"Description: {task.Description}"); Console.WriteLine(); bool saveChanges = NavigationTools.GetBoolYorN("Are you sure you want save these changes? [Y/N]: "); if (saveChanges) { ToDoApp.UpdateToDoTask(task); } } } }
private void EditToDoList() { bool inEditList = true; string name = String.Empty; string desc = String.Empty; TaskList taskList = new TaskList() { Id = ToDoApp.SelectedTaskList.Id, }; while (inEditList) { Console.Clear(); Console.WriteLine($"Name: {ToDoApp.SelectedTaskList.Name}"); Console.WriteLine($"Description: {ToDoApp.SelectedTaskList.Description}"); Console.WriteLine(); if (!String.IsNullOrEmpty(name)) { Console.WriteLine($"New Name: {name}"); } if (!String.IsNullOrEmpty(desc)) { Console.WriteLine($"New Description: {desc}"); } if (!String.IsNullOrEmpty(name) || !String.IsNullOrEmpty(desc)) { Console.WriteLine(); } Console.WriteLine("[1] Change Name"); Console.WriteLine("[2] Change Description"); Console.WriteLine("[3] Save your changes"); Console.WriteLine("[Q] Return to To Do Lists"); int selection = NavigationTools.SelectSingleIntegerOrQ(1, 3); if (selection == -1) { inEditList = false; if (CategoryView) { List <TaskList> taskLists = ToDoApp.GetTaskListsByCategoryId(ToDoApp.SelectedCategory.Id); DisplayToDoLists(taskLists); } else { DisplayToDoLists(ToDoApp.CurrentTaskLists); } } else if (selection == 1) { Console.WriteLine(); name = NavigationTools.SelectString("Please enter a new name: "); taskList.Name = name; } else if (selection == 2) { Console.WriteLine(); desc = NavigationTools.SelectString("Please enter a new description: "); taskList.Description = desc; } else if (selection == 3) { Console.Clear(); Console.WriteLine($"Name: {ToDoApp.SelectedTaskList.Name}"); Console.WriteLine($"Description: {ToDoApp.SelectedTaskList.Description}"); Console.WriteLine(); Console.WriteLine("To..."); Console.WriteLine(); Console.WriteLine($"Name: {taskList.Name}"); Console.WriteLine($"Description: {taskList.Description}"); Console.WriteLine(); bool saveChanges = NavigationTools.GetBoolYorN("Are you sure you want save these changes? [Y/N]: "); if (saveChanges) { ToDoApp.UpdateTaskList(taskList); } } } }
private void DisplayTaskListDetails() { bool inTaskListDetails = true; while (inTaskListDetails) { Console.Clear(); Console.WriteLine(); Console.WriteLine($"Name: {ToDoApp.SelectedTaskList.Name}"); Console.WriteLine($"Description: {ToDoApp.SelectedTaskList.Description}"); Console.WriteLine(); Console.WriteLine("[1] View Tasks"); Console.WriteLine("[2] Edit List"); Console.WriteLine("[3] Add a New Task"); Console.WriteLine("[4] Remove List and all of its Tasks"); Console.WriteLine("[Q] To return to the ToDo Lists"); int selection = NavigationTools.SelectSingleIntegerOrQ(1, 4); if (selection == -1) { inTaskListDetails = false; if (CategoryView) { List <TaskList> taskLists = ToDoApp.GetTaskListsByCategoryId(ToDoApp.SelectedCategory.Id); DisplayToDoLists(taskLists); } else { DisplayToDoLists(ToDoApp.CurrentTaskLists); } } else if (selection == 1) { inTaskListDetails = false; DisplayToDoTasks(); } else if (selection == 2) { inTaskListDetails = false; EditToDoList(); } else if (selection == 3) { inTaskListDetails = false; DisplayAddToDoTaskView(); } else if (selection == 4) { Console.WriteLine(); bool removeTaskList = NavigationTools.GetBoolYorN($"Are you sure you want permanently remove {ToDoApp.SelectedTaskList.Name}? [Y/N]: "); if (removeTaskList) { inTaskListDetails = false; ToDoApp.RemoveAllTasksByListId(ToDoApp.SelectedTaskList.Id); ToDoApp.RemoveTaskList(ToDoApp.SelectedTaskList.Id); if (CategoryView) { List <TaskList> taskLists = ToDoApp.GetTaskListsByCategoryId(ToDoApp.SelectedCategory.Id); DisplayToDoLists(taskLists); } else { DisplayToDoLists(ToDoApp.CurrentTaskLists); } } } } }