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 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(); } } } }
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); } } } }