public static List <Tasking> AddTask(List <Tasking> tasks) { DateTime due; Console.WriteLine("Add a new task"); Console.Write("Team member's name: "); string name = Console.ReadLine(); Console.Write("Task description: "); string description = Console.ReadLine(); Console.Write("When will it needed to be completed by?: "); while (!DateTime.TryParse(Console.ReadLine(), out due)) { Console.WriteLine("Enter a valid date mm/dd/yy"); Console.Write("When is it due: "); } string due1 = due.ToShortDateString(); Tasking newItems = new Tasking(name, description, due1); tasks.Add(newItems); Console.WriteLine("Task Entered!"); Console.WriteLine(); return(tasks); }
static void Main(string[] args) { List <string> menu = new List <string>() { "List Task", "Add Task", "Delete Task", "Mark Complete", "Edit Task", "Team Member Task List", "Quit Program" }; List <Tasking> tasks = new List <Tasking>(); Tasking newTask = new Tasking("Robbie Kress", "Better time management", "08/02/2020"); Tasking newTask1 = new Tasking("Papa John", "Add tipping system to PapaJohns.com", "08/20/202"); Tasking newTask2 = new Tasking("Papa Junior", "Is going to be in the house", "09/28/2020"); Tasking newTask3 = new Tasking("Little Ceasers", "Change name to Little Seizures", "11/11/1111"); tasks.Add(newTask); tasks.Add(newTask1); tasks.Add(newTask2); tasks.Add(newTask3); while (true) { Console.WriteLine("Main Menu"); Tasking.ListMenu(menu); string choice = Tasking.UserChoice(); if (choice == "1") { Console.WriteLine(); Tasking.ListTasks(tasks); } if (choice == "2") { Console.WriteLine(); Tasking.AddTask(tasks); } if (choice == "3") { Console.WriteLine(); Tasking.DeleteTask(tasks); } if (choice == "4") { Console.WriteLine(); Tasking.MarkComplete(tasks); } if (choice == "5") { Console.WriteLine(); Tasking.EditTask(tasks); } if (choice == "6") { Console.WriteLine(); Tasking.PrintUserTasks(tasks); } if (choice == "7") { Console.WriteLine(); Console.WriteLine("Buh bye"); break; } } }
public static List <Tasking> MarkComplete(List <Tasking> tasks) { Tasking.ListTasks(tasks); Console.Write("Which task do you want to mark complete? "); int choice = 0; string answer; while (true) { try { choice = int.Parse(Console.ReadLine()); if (choice <= 0 || choice > tasks.Count) { throw new Exception("Enter a number in range "); } } catch (FormatException) { Console.Write("That is not a number! Enter a number in range: "); } catch (Exception e) { Console.Write(e.Message); } if (choice <= tasks.Count && choice > 0) { Console.WriteLine(); Console.WriteLine($"{choice}. {tasks[choice - 1].TeamMemberName,-25}|Due on {tasks[choice - 1].DueDate,-10} |Completion status: {tasks[choice - 1].Complete} | Description = {tasks[choice - 1].TaskDescription}."); Console.WriteLine(); while (true) { Console.Write("Are you sure you wish to mark complete? y/n "); answer = Console.ReadLine(); if (answer == "y") { tasks[choice - 1].Complete = true; Console.WriteLine($"Task {choice} completed!"); Console.WriteLine(); break; } if (answer == "n") { Console.WriteLine($"Task {choice} not changed"); Console.WriteLine(); break; } Console.WriteLine("Enter y or n!"); } break; } } return(tasks); }
public static List <Tasking> DeleteTask(List <Tasking> tasks) { Tasking.ListTasks(tasks); Console.Write("Which task would you like to delete? "); int choice = 0; string answer; //honestly thought this was spelt wrong just remembering your comment. while (true) { try { choice = int.Parse(Console.ReadLine()); if (choice <= 0 || choice > tasks.Count) { throw new Exception("Enter a number in range "); } } catch (FormatException) { Console.Write("That is not a number! Enter a number in range: "); } catch (Exception e) { Console.Write(e.Message); } if (choice <= tasks.Count && choice > 0) { Console.WriteLine(); Console.WriteLine($"{choice}. {tasks[choice - 1].TeamMemberName,-25}|Due on {tasks[choice - 1].DueDate,-10} |Completion status: {tasks[choice - 1].Complete} | Description = {tasks[choice - 1].TaskDescription}."); Console.WriteLine(); while (true) { Console.Write("Are you sure you wish to delete? y/n "); answer = Console.ReadLine(); if (answer == "y") { tasks.RemoveAt(choice - 1); Console.WriteLine($"Task {choice} deleted!"); Console.WriteLine(); break; } if (answer == "n") { Console.WriteLine($"Task {choice} not changed"); Console.WriteLine(); break; } Console.WriteLine("Enter y or n!"); } break; } } return(tasks); }
public static List <Tasking> EditTask(List <Tasking> tasks) { Tasking.ListTasks(tasks); Console.Write("Which task do you want to edit? "); int choice = 0; string answer; bool var; while (true) { try { choice = int.Parse(Console.ReadLine()); if (choice <= 0 || choice > tasks.Count) { throw new Exception("Enter a number in range "); } } catch (FormatException) { Console.Write("That is not a number! Enter a number in range: "); } catch (Exception e) { Console.Write(e.Message); } if (choice <= tasks.Count && choice > 0) { Console.WriteLine(); Console.WriteLine($"{choice}. {tasks[choice - 1].TeamMemberName,-25}|Due on {tasks[choice - 1].DueDate,-10} |Completion status: {tasks[choice - 1].Complete} | Description = {tasks[choice - 1].TaskDescription}."); Console.WriteLine(); while (true) { Console.Write("Are you sure you wish to edit? y/n "); answer = Console.ReadLine(); if (answer == "y") { DateTime due; Console.WriteLine("EDIT TASK"); Console.Write("Team member name: "); string name = Console.ReadLine(); Console.Write("Task description: "); string description = Console.ReadLine(); Console.Write("When is it due: "); while (!DateTime.TryParse(Console.ReadLine(), out due)) { Console.WriteLine("Enter a valid date mm/dd/yy"); Console.Write("When is it due: "); } string due1 = due.ToShortDateString(); Console.Write("Is it complete? true or false: "); while (!bool.TryParse(Console.ReadLine(), out var)) { Console.WriteLine("Enter true or false "); Console.Write("Is it complete? "); } tasks[choice - 1].TeamMemberName = name; tasks[choice - 1].DueDate = due1; tasks[choice - 1].TaskDescription = description; tasks[choice - 1].Complete = var; Console.WriteLine($"Task {choice} edited!"); Console.WriteLine(); break; } if (answer == "n") { Console.WriteLine($"Task {choice} not changed"); Console.WriteLine(); break; } Console.WriteLine("Enter y or n! "); } break; } } return(tasks); }