static void ManipulateTask() { Console.Write("Press 1 to make a new task, or press 2 to delete a task: "); string readOrDel = string.Empty; while (true) { readOrDel = Console.ReadLine(); if (readOrDel != "1" && readOrDel != "2") { Console.WriteLine("Incorect choice! Please try again!"); } else if (readOrDel == "1") { TaskMaker(); string choice = string.Empty; while (true) { Console.Write("Do you want to make another task? yes/no"); choice = Console.ReadLine(); if (choice != "yes" && choice != "no") { Console.WriteLine("Incorect choice! Please try again!"); } else if (choice == "yes") { TaskMaker(); } else if (choice == "no") { Console.WriteLine("Good luck!"); Console.Write("Press any key to exit:"); return; } } } else if (readOrDel == "2") { XMLTaskReader reader = new XMLTaskReader(); List <Task> tasks = reader.ReadTasks("../../tasks.xml"); Console.Write("Select the number of the task, you want to delete: "); int n = int.Parse(Console.ReadLine()); XMLTaskWriter writer = new XMLTaskWriter(); writer.Delete(tasks[n - 1]); Console.WriteLine("Delete completed!"); break; } } }
static void ReadTasks() { XMLTaskReader reader = new XMLTaskReader(); string path = "../../tasks.xml"; if (!File.Exists(path)) { Console.WriteLine("There is no saved task's!"); return; } else { List <Task> tasks = reader.ReadTasks(path); int count = 1; foreach (var item in tasks) { Console.WriteLine("Task {0}:\n{1}\nDescription: {2}\nstarted at: {3}\nterm to: {4}", count, item.Title, item.Message, item.StartDate, item.EndDate); count++; Console.WriteLine(); } } }