public void ProcessInput() { //Display menu DisplayALL(); Console.WriteLine(); string AppAction = ConsoleUtils.DisplayMenu(); while (AppAction != "Exit") { switch (AppAction) { case "List": DisplayALL(); break; case "Add": string[] newItemInfo = ConsoleUtils.ItemUserInput(); repo.AddItem(newItemInfo[0], newItemInfo[1]); //DateTime.Parse(newItem[2]) DisplayALL(); break; case "Delete": //ask usr for id int itemID = ConsoleUtils.GetItemID(); //remove repo.DeleteItem(itemID); DisplayALL(); break; case "Update": itemID = ConsoleUtils.GetItemID(); string[] updatedItemInfo = ConsoleUtils.ItemUserInput(); repo.UpdateItem(itemID, updatedItemInfo[0], updatedItemInfo[1]); //, DateTime.Parse(updatedItem[2]) DisplayALL(); break; case "Pending": ConsoleUtils.PrintAllItems(repo.GetPendingItems()); Console.WriteLine(); DisplayALL(); break; case "Done": ConsoleUtils.PrintAllItems(repo.GetPendingItems()); Console.WriteLine(); DisplayALL(); break; case "Exit": DisplayALL(); ConsoleUtils.QuitProgram(); break; default: Console.WriteLine("You have entered an invalid option. Please try again."); break; } AppAction = ConsoleUtils.DisplayMenu(); } }
public void ProcessInput() { //Display menu //DisplayALL(); string action = ConsoleUtils.DisplayMenu(); while (action != "Exit") { switch (action) { case "List": DisplayALL(); break; case "Add": string[] newItem = ConsoleUtils.ItemUserInput(); repo.AddItem(newItem[0], newItem[1]); DisplayALL(); break; case "Delete": int itemID = ConsoleUtils.GetItemID(); repo.DeleteItem(itemID); DisplayALL(); break; case "Edit": itemID = ConsoleUtils.GetItemID(); string[] updatedItem = ConsoleUtils.ItemUserInput(); repo.UpdateItem(itemID, updatedItem[0], updatedItem[1]); DisplayALL(); break; case "Pending": repo.GetPendingItems(); Console.WriteLine(); DisplayALL(); break; case "Done": repo.GetDoneItems(); Console.WriteLine(); DisplayALL(); break; case "Exit": DisplayALL(); Console.WriteLine("You have now quit the program"); break; default: Console.WriteLine("You have entered an invalid option. Please try again."); break; } action = ConsoleUtils.DisplayMenu(); } }
public void Run() { string answer = ConsoleUtils.DisplayMenu(); //UI and Menu Display after string while (answer != "Q") { if (answer == "L") { repo.GetToDoItems(); List <ToDoItems> list = repo.GetToDoItems(); ConsoleUtils.PrintToDoItems(list); } if (answer == "A") { Console.WriteLine("Add a Description: "); string Description = Console.ReadLine(); //strings for input Console.WriteLine("Enter a Importance Status for item: (Low, Medium, High) "); string Status = Console.ReadLine(); Console.WriteLine("Enter a Due Date: month/day/year "); DateTime DueDate = Convert.ToDateTime(Console.ReadLine()); repo.AddItem(Description, Status, DueDate); } if (answer == "U") { Console.WriteLine(" What is the ID of what needs to be updated: "); int Id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Update your Description of the item: "); string Description = Console.ReadLine(); Console.WriteLine("Update Importance Status of the item: "); string Status = Console.ReadLine(); Console.WriteLine("Update your due date of the item: "); DateTime DueDate = Convert.ToDateTime(Console.ReadLine()); repo.UpdateItem(Id, Description, Status, DueDate); } if (answer == "R") { Console.WriteLine("What is the ID of the item you want to Delete: "); int Id = Convert.ToInt32(Console.ReadLine()); repo.DeleteItem(Id); } answer = ConsoleUtils.DisplayMenu(); } }
//Main driving method public void Start() { //Calls DisplayAll method as well as the command list. DisplayAll(); string command = ConsoleUtil.GetCommands(); bool quit = false; bool update = false; string updateSelect = ""; bool verifyID = true; bool verifyStat = true; //While the program is not in a "quit" state then run while (!quit) { //Ensures that the command given is actually valid CommandValidate(command); if (CommandValidate(command) == false) { ConsoleUtil.BadAction(); } //Switch statement handles command scenarios switch (command) { //Asks user for description of ToDo Item //Once done, the item is generated and added to the list case "Add": update = true; string newDesc = ConsoleUtil.GetDescription(update); ItemRepository.AddItem(newDesc); DisplayAll(); break; case "Delete": do { //Asks user to select ID and verifies ID to ensure it's valid. int delItemID = ConsoleUtil.GetItemID(command); verifyID = Itemrepo.ItemIDVerify(delItemID); if (verifyID == false) { //If not valid, then calls BadID method DisplayAll(); ConsoleUtil.BadID(); } else { //If valid then call DeleteItem method with given ID //Then display updated list Itemrepo.DeleteItem(delItemID); DisplayAll(); } //Ensures that this case is looped while ID is invalid } while (!verifyID); break; case "Update": do { update = true; //User is asked to select an ID to update int itemID = ConsoleUtil.GetItemID(command); //Verifies ID is valid verifyID = Itemrepo.ItemIDVerify(itemID); if (verifyID == false) { //If not, call BadID method to prompt user ConsoleUtil.BadID(); } else { //If ID is valid, prompts user to select either "description" or "status" to update updateSelect = ConsoleUtil.UpdateSelect(itemID); if (updateSelect == "description") { //If "description" is selected then automatically set the status update to false bool statUpdate = false; //Grabs new description newDesc = ConsoleUtil.GetDescription(update); //Status stays the same string newStat = ConsoleUtil.GetStatus(statUpdate); //Generates updated ToDo Itm Itemrepo.UpdateItem(itemID, newDesc, newStat); } else if (updateSelect == "status") { do { //If status is to be updated //Automatically sets "description" update to false bool descUpdate = false; //Prompts user for new status and grabs string string newStat = ConsoleUtil.GetStatus(update); //Verifies that it is a valid status verifyStat = StatusValidate(newStat); if (verifyStat == false) { //If not a valid status, prompts user to Bad Status ConsoleUtil.BadStatus(); } else { //If valid then description stays the same then generates updated ToDo Item newDesc = ConsoleUtil.GetDescription(descUpdate); Itemrepo.UpdateItem(itemID, newDesc, newStat); } //While loop ensures that case is looped while an invalid status persists } while (verifyStat == false); } //Anything other than "description" or "status" will result in the invalid action prompt //And sets the verifyID to false so the case will get looped again else { ConsoleUtil.BadAction(); verifyID = false; } } //While loop ensures Update case is looped while ID is invalid } while (!verifyID); //Displays the list with updated items DisplayAll(); break; case "Filter": //Runs DisplayFilter method and that method handles everything for this case DisplayFilter(); break; case "Quit": //Calls the QuitProtocol and sets quit to be true so it can exit out of the program loop Itemrepo.QuitProtocol(); quit = true; break; } if (quit == true) { //Then prompts user with exit message ConsoleUtil.QuitMessage(); } else { //Still uses the program then displays commands command = ConsoleUtil.GetCommands(); } } }
public void UpdateItem(int Id, string Description, string Status, string DueDate) { repo.UpdateItem(Id, Description, Status, DueDate); }