public void TestAddNewTask() { ToDoApp testApp = new ToDoApp(); ToDoTask testTask = new ToDoTask() { Name = "Test Task Name", Description = "Test Task Description", ListId = Guid.NewGuid() }; testApp.AddNewTask(testTask); int expectedCount = 1; string expectedName = testTask.Name; string expectedDesc = testTask.Description; Guid? expectedListId = testTask.ListId; Guid? expectedId = testTask.Id; ToDoTask addedToDoTask = testApp.CurrentToDoTasks.Find(t => t.Id == testTask.Id); int actualCount = testApp.CurrentToDoTasks.Count; string actualName = addedToDoTask.Name; string actualDesc = addedToDoTask.Description; Guid? actualListId = addedToDoTask.ListId; Guid? actualId = addedToDoTask.Id; Assert.AreEqual(expectedCount, actualCount); Assert.AreEqual(expectedName, actualName); Assert.AreEqual(expectedDesc, actualDesc); Assert.AreEqual(expectedListId, actualListId); Assert.AreEqual(expectedId, actualId); }
public void RemoveTask() { ToDoApp testApp = new ToDoApp(); ToDoTask testTask = new ToDoTask() { Name = "Test Task Name", Description = "Test Task Description", ListId = Guid.NewGuid(), }; testApp.CurrentToDoTasks.Add(testTask); ToDoTask testTaskTwo = new ToDoTask() { Name = "Test Task Name", Description = "Test Task Description", ListId = Guid.NewGuid(), }; testApp.CurrentToDoTasks.Add(testTaskTwo); testApp.RemoveTask(testTask.Id); int expectedCount = 1; int actualCount = testApp.CurrentToDoTasks.Count; Assert.AreEqual(expectedCount, actualCount); }
private void DisplayTaskListsCategoryView() { bool inCategoryView = true; while (inCategoryView) { Console.Clear(); Console.WriteLine("Practice ToDo App: Category View"); Console.WriteLine(); int counter = 1; foreach (Category category in ToDoApp.CurrentCategories) { Console.WriteLine($"[{counter}] {category.Name}"); counter++; } Console.WriteLine(); Console.WriteLine("[Q] To Return to the Main Menu"); int selection = NavigationTools.SelectSingleIntegerOrQ(1, ToDoApp.CurrentCategories.Count); if (selection == -1) { inCategoryView = false; MainMenu(); } else if (selection <= ToDoApp.CurrentCategories.Count && selection > 0) { inCategoryView = false; List <TaskList> taskLists = ToDoApp.GetTaskListsByCategoryId(ToDoApp.CurrentCategories[selection - 1].Id); ToDoApp.SetSelectedCategory(ToDoApp.CurrentCategories[selection - 1].Name); DisplayToDoLists(taskLists); } } }
public void TestUpdateTaskList() { ToDoApp testPracticeApp = new ToDoApp(); TaskList testTaskList = new TaskList() { Name = "Test Task List", Description = "Testing the Task List" }; testPracticeApp.CurrentTaskLists.Add(testTaskList); TaskList updatedTaskList = new TaskList() { Name = "Test Task List Test Test", Description = "Testing the Task List Test Test", Id = testTaskList.Id }; testPracticeApp.UpdateTaskList(updatedTaskList); string expectedName = updatedTaskList.Name; string expectedDesc = updatedTaskList.Description; Guid? expectedId = updatedTaskList.Id; TaskList addedTaskList = testPracticeApp.CurrentTaskLists.Find(t => t.Id == testTaskList.Id); string actualName = addedTaskList.Name; string actualDesc = addedTaskList.Description; Guid? actualId = addedTaskList.Id; Assert.AreEqual(expectedName, actualName); Assert.AreEqual(expectedDesc, actualDesc); Assert.AreEqual(expectedId, actualId); }
public void OnGet() { using (var db = new ToDoApp()) { Users = db.Users.ToList(); Tasks = db.Tasks.Include("User").Include("Category").ToList(); } }
public void OnGet() { using (var db = new ToDoApp()) { Tasks = (from t in db.Tasks orderby t.TaskDescription ascending select t).Include("User").Include("Category").ToList(); } }
public void OnGet() { using (var db = new ToDoApp()) { Tasks = (from t in db.Tasks orderby t.TaskDescription ascending select new CustomTask { TaskDescription = t.TaskDescription, CategoryID = t.CategoryID }) .ToList(); } }
public void OnGet() { using (var db = new ToDoApp()) { TaskStats = (from t in db.Tasks group t by t.CategoryID into categories select new TaskStats { Count = categories.Count(), CategoryID = categories.Key }) .ToList(); } }
public void TestGetToDoTasksByListId_ExpectedListOfToDoTasks() { List <TaskList> taskLists = new List <TaskList>(); List <ToDoTask> toDoTasks = new List <ToDoTask>(); int numberOfListsToMake = 3; int numberOfTasksPerList = 3; for (int i = 1; i <= numberOfListsToMake; i++) { TaskList taskList = new TaskList() { Name = $"Test List #{i}", Description = $"Test Desc {i}" }; taskLists.Add(taskList); for (int x = 1; x <= numberOfTasksPerList; x++) { ToDoTask toDoTask = new ToDoTask() { Name = $"Test Task #{x} for {taskList.Name}", Description = $"Test Desc {x} for {taskList.Description}", ListId = taskList.Id }; toDoTasks.Add(toDoTask); } } ToDoApp testPracticeApp = new ToDoApp(taskLists, toDoTasks); int selectedListForTest = 2; int taskSelectBaseOnList = (selectedListForTest * 3) - 2; List <ToDoTask> tasksFromList = testPracticeApp.GetToDoTasksByListId(testPracticeApp.CurrentTaskLists[selectedListForTest - 1].Id); int expectedListCount = numberOfTasksPerList; string expectedTaskName = toDoTasks[taskSelectBaseOnList].Name; string expectedTaskDesc = toDoTasks[taskSelectBaseOnList].Description; Guid? expectedTaskId = toDoTasks[taskSelectBaseOnList].ListId; int actualListCount = tasksFromList.Count; string actualTaskName = tasksFromList[1].Name; string actualTaskDesc = tasksFromList[1].Description; Guid? actualTaskId = tasksFromList[1].ListId; Assert.AreEqual(expectedListCount, actualListCount); Assert.AreEqual(expectedTaskName, actualTaskName); Assert.AreEqual(expectedTaskDesc, actualTaskDesc); Assert.AreEqual(expectedTaskId, actualTaskId); }
public void TestRemoveTaskList() { ToDoApp testPracticeApp = new ToDoApp(); #region Create Three TaskLists TaskList testTaskList = new TaskList() { Name = "Test Task List 1", Description = "Testing the Task List 1", }; testPracticeApp.CurrentTaskLists.Add(testTaskList); TaskList testTaskListTwo = new TaskList() { Name = "Test Task List 2", Description = "Testing the Task List 2", }; testPracticeApp.CurrentTaskLists.Add(testTaskListTwo); TaskList testTaskListThree = new TaskList() { Name = "Test Task List 3", Description = "Testing the Task List 3", }; testPracticeApp.CurrentTaskLists.Add(testTaskListThree); #endregion testPracticeApp.RemoveTaskList(testTaskListTwo.Id); int expectedCount = 2; string expectedTaskListName = testTaskListThree.Name; string expectedTaskListDesc = testTaskListThree.Description; int actualTaskListCount = testPracticeApp.CurrentTaskLists.Count; string actualTaskListName = testPracticeApp.CurrentTaskLists[1].Name; string actualTaskListDesc = testPracticeApp.CurrentTaskLists[1].Description; Assert.AreEqual(expectedCount, actualTaskListCount); Assert.AreEqual(expectedTaskListName, actualTaskListName); Assert.AreEqual(expectedTaskListDesc, actualTaskListDesc); }
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(); } } } }
public void TestUpdateToDoTask() { ToDoApp testApp = new ToDoApp(); ToDoTask testTask = new ToDoTask() { Name = "Test Task Name", Description = "Test Task Description", ListId = Guid.NewGuid(), }; testApp.CurrentToDoTasks.Add(testTask); ToDoTask updatedTask = new ToDoTask() { Name = "Name Test Task", Description = "Description Test Task", ListId = testTask.ListId, Id = testTask.Id }; testApp.UpdateToDoTask(updatedTask); string expectedName = updatedTask.Name; string expectedDesc = updatedTask.Description; Guid? expectedListId = updatedTask.ListId; Guid? expectedId = updatedTask.Id; ToDoTask addedToDoTask = testApp.CurrentToDoTasks.Find(t => t.Id == testTask.Id); string actualName = addedToDoTask.Name; string actualDesc = addedToDoTask.Description; Guid? actualListId = addedToDoTask.ListId; Guid? actualId = addedToDoTask.Id; Assert.AreEqual(expectedName, actualName); Assert.AreEqual(expectedDesc, actualDesc); Assert.AreEqual(expectedListId, actualListId); Assert.AreEqual(expectedId, actualId); }
public void TestRemoveAllTasksByListId() { List <TaskList> taskLists = new List <TaskList>(); List <ToDoTask> toDoTasks = new List <ToDoTask>(); int numberOfListsToMake = 3; int numberOfTasksPerList = 3; for (int i = 1; i <= numberOfListsToMake; i++) { TaskList taskList = new TaskList() { Name = $"Test List #{i}", Description = $"Test Desc {i}" }; taskLists.Add(taskList); for (int x = 1; x <= numberOfTasksPerList; x++) { ToDoTask toDoTask = new ToDoTask() { Name = $"Test Task #{x} for {taskList.Name}", Description = $"Test Desc {x} for {taskList.Description}", ListId = taskList.Id }; toDoTasks.Add(toDoTask); } } ToDoApp testPracticeApp = new ToDoApp(taskLists, toDoTasks); testPracticeApp.RemoveAllTasksByListId(testPracticeApp.CurrentTaskLists[0].Id); int expectedCount = (numberOfListsToMake - 1) * numberOfTasksPerList; int actualCount = testPracticeApp.CurrentToDoTasks.Count; Assert.AreEqual(expectedCount, actualCount); }
public void TestSetSelectedTaskList() { ToDoApp testPracticeApp = new ToDoApp(); TaskList testTaskList = new TaskList() { Name = "Test Task List", Description = "Testing the Task List", }; testPracticeApp.CurrentTaskLists.Add(testTaskList); testPracticeApp.SetSelectedTaskList(testTaskList.Id); string expectedName = testTaskList.Name; string expectedDesc = testTaskList.Description; Guid? expectedId = testTaskList.Id; string actualName = testPracticeApp.SelectedTaskList.Name; string actualDesc = testPracticeApp.SelectedTaskList.Description; Guid? actualId = testPracticeApp.SelectedTaskList.Id; Assert.AreEqual(expectedName, actualName); Assert.AreEqual(expectedDesc, actualDesc); Assert.AreEqual(expectedId, actualId); }
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 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); } } } }
static void Main(string[] args) { #region Categories Category codingListCategory = new Category() { Name = "Coding Lists" }; Category shoppingListCategory = new Category() { Name = "Shopping Lists" }; Category socialDistanceCategory = new Category() { Name = "Goverment Mandated Lists" }; List <Category> categories = new List <Category>() { codingListCategory, shoppingListCategory, socialDistanceCategory }; #endregion #region TaskLists TaskList TaskListOne = new TaskList() { Name = "Code!", Description = "Eat Sleep Code", CategoryId = codingListCategory.Id }; TaskList TaskListTwo = new TaskList() { Name = "Social Distancing", Description = "Maintain a healthy isolation from others", CategoryId = socialDistanceCategory.Id }; TaskList TaskListThree = new TaskList() { Name = "Grocery List", Description = "Things to get from the store", CategoryId = shoppingListCategory.Id }; List <TaskList> taskLists = new List <TaskList>() { TaskListOne, TaskListTwo, TaskListThree }; #endregion #region Tasks //task for list 1: Code! ToDoTask taskOne = new ToDoTask() { Name = "Add CRUD Methods", Description = "Continue adding CRUD methods to your practice ToDo App", ListId = TaskListOne.Id }; ToDoTask taskTwo = new ToDoTask() { Name = "Add Unit Tests", Description = "you should of been adding unit tests from the start", ListId = TaskListOne.Id }; ToDoTask taskThree = new ToDoTask() { Name = "Seriously Add Unit Tests", Description = "Before creating a the CRUD method, you should write the Unit Test...Seriously", ListId = TaskListOne.Id }; //tasks for list 2: Social Distancing ToDoTask taskFour = new ToDoTask() { Name = "Avoid People", Description = "Stay a minimum of 6ft away from others and avoid human contact as much as possible.", ListId = TaskListTwo.Id }; ToDoTask taskFive = new ToDoTask() { Name = "Get a pet", Description = "Get a cat or a dog or something you can cuddle. Studies show this reduces stress!", ListId = TaskListTwo.Id }; ToDoTask taskSix = new ToDoTask() { Name = "Pet your pet", Description = "Give your pet all the love and attention you can no longer get from people", ListId = TaskListTwo.Id }; //tasks for lists 3: Grocery List ToDoTask taskSeven = new ToDoTask() { Name = "Skyline Chili", Description = "Cans of Skyline Chili, as many as you can get.", ListId = TaskListThree.Id }; ToDoTask taskEight = new ToDoTask() { Name = "Shredded Cheese", Description = "All of the shredded cheese. Yes all of it.", ListId = TaskListThree.Id }; ToDoTask taskNine = new ToDoTask() { Name = "Pasta of your choice", Description = "I like spaghetti noodles, but equally as good over penne or fetticini or even rice!", ListId = TaskListThree.Id }; List <ToDoTask> toDoTasks = new List <ToDoTask>() { taskOne, taskTwo, taskThree, taskFour, taskFive, taskSix, taskSeven, taskEight, taskNine }; #endregion #region Extra Lists and Tasks int numberOfListsToMake = 43; int numberOfTasksPerList = 43; Category extraCategory = new Category() { Name = "Category: Extra Lists" }; categories.Add(extraCategory); for (int i = 1; i <= numberOfListsToMake; i++) { TaskList taskList = new TaskList() { Name = $"Extra List #{i}", Description = $"Extra Desc {i}", CategoryId = extraCategory.Id }; taskLists.Add(taskList); for (int x = 1; x <= numberOfTasksPerList; x++) { ToDoTask toDoTask = new ToDoTask() { Name = $"Extra Task #{x} for {taskList.Name}", Description = $"Extra Desc {x} for {taskList.Description}", ListId = taskList.Id }; toDoTasks.Add(toDoTask); } } #endregion ToDoApp toDoApp = new ToDoApp(taskLists, toDoTasks, categories); PracticeAppCLI appCLI = new PracticeAppCLI(toDoApp); appCLI.MainMenu(); }
private void DisplayToDoLists(List <TaskList> taskLists) { bool inDisplayToDoLists = true; bool multiPage = false; int pageCount = 1; if (NumberOfTaskListstoDisplayPerPage < taskLists.Count) { multiPage = true; } while (inDisplayToDoLists) { Console.Clear(); Console.WriteLine("Practice ToDo Console App: Currently Viewing Task Lists"); Console.WriteLine(); if (!multiPage) { int counter = 1; foreach (TaskList taskList in taskLists) { Console.WriteLine($"[{counter}] {taskList.Name}"); counter++; } } else { if (pageCount == 1) { int counter = 1; foreach (TaskList taskList in taskLists) { if (counter <= NumberOfTaskListstoDisplayPerPage) { Console.WriteLine($"[{counter}] {taskList.Name}"); } counter++; } Console.WriteLine(); Console.WriteLine("[F] Next Page"); } if (pageCount > 1) { Console.WriteLine($"Page #{pageCount}"); int counter = 1; foreach (TaskList taskList in taskLists) { if ((counter <= (NumberOfTaskListstoDisplayPerPage * pageCount)) && counter > (NumberOfTaskListstoDisplayPerPage * (pageCount - 1))) { Console.WriteLine($"[{counter}] {taskList.Name}"); } counter++; } Console.WriteLine(); Console.WriteLine("[B] Previous Page"); if (taskLists.Count > NumberOfTaskListstoDisplayPerPage * pageCount) { Console.WriteLine("[F] Next Page"); } } } Console.WriteLine("[Q] Return to Main Menu"); int selection = NavigationTools.SelectIntegerOrQorForB("Select a list to view or make changes", 1, ToDoApp.CurrentTaskLists.Count); if (selection == -1) { inDisplayToDoLists = false; MainMenu(); } else if (selection == -2) { pageCount++; } else if (selection == -3) { pageCount--; } else if (selection > 0 && selection <= ToDoApp.CurrentTaskLists.Count) { ToDoApp.SetSelectedTaskList(ToDoApp.CurrentTaskLists[selection - 1].Id); DisplayTaskListDetails(); inDisplayToDoLists = false; } } }
static void Choose_a_demo() { var frm = new Form(0, 0, Console.WindowWidth, Console.WindowHeight) { Title = "Choose a demo" }; var mnusw = frm.MenuBar.Menu.AddItem("Single widgets"); mnusw.Submenu.AddItem("Lbls", "mnuLabels"); mnusw.Submenu.AddItem("Texts", "mnuText"); mnusw.Submenu.AddItem("Options", "mnuOptions"); mnusw.Submenu.AddItem("Lists", "mnuLists"); mnusw.Submenu.AddItem("Dialogs") .Submenu.AddItems(new[] { new MenuItem("MsgBox", "mnuMsgBox"), new MenuItem("FileSys", "mnuFileSys") }); var mnusc = frm.MenuBar.Menu.AddItem("Scenarios"); mnusc.Submenu.AddItem("ToDo App", "mnuToDo"); frm.MenuBar.Menu.AddItem("Exit", "mnuExit"); frm.MenuBar.OnSelected += (mnuItem, e) => { switch (mnuItem.Name) { case "mnuExit": BashForms.Close(); break; case "mnuLabels": Test_labels(); break; case "mnuText": Test_text_editing(); break; case "mnuOptions": Test_options(); break; case "mnuLists": Test_lists(); break; case "mnuMsgBox": Test_messageboxes(); break; case "mnuFileSys": Test_filesystemdlg(); break; case "mnuToDo": ToDoApp.Enterypoint(); break; } }; frm.AddChild(new Label(2, 3, 40) { Text = "* Press F2 to enter menu.\n* Use left/right arrow to move between menu item.\n* Use ENTER to select menu item/enter next menu level.\n* Use ESC to back up menu level.\n\n* Use (shift-)TAB to move between controls.\n\n* Use F5 to refresh screen.", CanBeMultiline = true, ForegroundColor = ConsoleColor.DarkGray }); BashForms.Open(frm); }
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 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); } } } } }
private void DisplayToDoTasks() { bool inDisplayToDoTasks = true; int pageCount = 1; bool multiPage = false; List <ToDoTask> toDoTasks = ToDoApp.GetToDoTasksByListId(ToDoApp.SelectedTaskList.Id); while (inDisplayToDoTasks) { Console.Clear(); Console.WriteLine(); if (toDoTasks.Count > NumberOfToDoTasksToDisplayPerPage) { multiPage = true; } if (!multiPage) { int counter = 1; foreach (ToDoTask task in toDoTasks) { Console.WriteLine($"[{counter}] {task.Name}"); counter++; } } else { if (pageCount == 1) { int counter = 1; foreach (ToDoTask task in toDoTasks) { if (counter <= NumberOfToDoTasksToDisplayPerPage) { Console.WriteLine($"[{counter}] {task.Name}"); } counter++; } Console.WriteLine(); Console.WriteLine("[F] Next Page"); } if (pageCount > 1) { int counter = 1; foreach (ToDoTask task in toDoTasks) { if ((counter <= (NumberOfToDoTasksToDisplayPerPage * pageCount)) && counter > (NumberOfToDoTasksToDisplayPerPage * (pageCount - 1))) { Console.WriteLine($"[{counter}] {task.Name}"); } counter++; } Console.WriteLine(); Console.WriteLine("[B] Previous Page"); if (toDoTasks.Count > NumberOfTaskListstoDisplayPerPage * pageCount) { Console.WriteLine("[F] Next Page"); } } } Console.WriteLine("[Q] Return to To Do Lists"); Console.WriteLine(); int selection = NavigationTools.SelectIntegerOrQorForB("Select a ToDo Task to see more details...", 1, toDoTasks.Count); if (selection == -1) { inDisplayToDoTasks = false; if (CategoryView) { List <TaskList> taskLists = ToDoApp.GetTaskListsByCategoryId(ToDoApp.SelectedCategory.Id); DisplayToDoLists(taskLists); } else { DisplayToDoLists(ToDoApp.CurrentTaskLists); } } else if (selection == -2) { pageCount++; } else if (selection == -3) { pageCount++; } else if (selection > 0 && selection <= toDoTasks.Count) { inDisplayToDoTasks = false; ToDoApp.SetSelectedToDoTask(toDoTasks[(selection - 1)].Id); DisplayToDoTaskDetails(); } } }
public PracticeAppCLI(ToDoApp toDoApp) { ToDoApp = toDoApp; }