private static void DeleteTaskListByName()//Delete tasklist using name { Console.Write("Delete some taskList ? (%Title%): "); string answer14 = Console.ReadLine(); if (!answer14.Equals("")) { ToDoTaskList list = MainControl.FindList(answer14, currentUser); if (list != null) // If list exist { MainControl.Delete(list); Console.WriteLine("List with name \"" + answer14 + "\" has been succesfully deleted"); currentUser = UserLab.Get().GetUser(currentUser.Id); // Refresh current user if (currentList != null) { if (answer14 == currentList.Title) // If deleted list with current name has been deleted, refresh current list { currentList = null; } } } else { Console.WriteLine("List with name: \"" + answer14 + "\" not found"); } } }
private static void CreateTaskList()//Create new list { Console.Write("Create new taskList? (%Title%): "); string answer11 = Console.ReadLine(); if (!answer11.Equals("")) { currentUser = MainControl.Add(answer11, currentUser); // Add new List to ListOfList and refresh currentUser link Console.WriteLine("Task List \"" + currentUser.ListOfLists.Last().Title + "\" has been created "); } }
private static void RenameCurrentList()//Modify tasklist { Console.Write("Current title: \"" + currentList.Title + "\"; Input new title: "); string answerTitle = Console.ReadLine(); if (!answerTitle.Equals("")) { currentList.Title = answerTitle; currentUser = MainControl.Modify(currentList, currentUser); currentList = MainControl.FindList(answerTitle, currentUser); // Refresh. Console.WriteLine("You modified list with name \"" + currentList.Title + "\"; and id: " + currentList.Id); } }
private static void AddTaskInCurrentList()//Adding new task in current list { Console.Write("Add new task in current list ? (%TitleTask%): "); string answer12 = Console.ReadLine(); if (!answer12.Equals("")) { Console.Write("Input new task: "); string answerNewTask = Console.ReadLine(); currentUser = MainControl.Add(answer12, answerNewTask, currentList, currentUser); currentList = MainControl.FindList(currentList.Title, UserLab.Get().GetUser(currentUser.Id)); ToDoTask task = MainControl.FindTask(answer12, currentList); Console.WriteLine("\nIn tasklist \"" + currentList.Title + "\" succesfully has been added new task \"" + task.Title + "\""); } }
private static bool RegLogAction(bool newUser) //Registration or loginin user { if (newUser) { Console.Write("Username: "******"First name: "); string firstName = Console.ReadLine(); Console.Write("Last name: "); string lastName = Console.ReadLine(); Console.Write("Password: "******"") & !password.Equals("")) { currentUser = MainControl.UserRegistration(username, firstName, lastName, password); if (currentUser != null) { Console.WriteLine("\nYou are successfully registered!"); } else { Console.WriteLine("\nUser already does exist"); } } else { Console.WriteLine("Filds \"Username\" and \"Password\" are required."); } Console.ReadKey(); return(false); } // LoginIn else { Console.Write("Username: "******"Password: "******"\n User not founded "); Console.ReadKey(); return(false); } return(true); } }
private static void DeleteTaskInCurrentListByName()//Delete task in current taskList using name { Console.Write("Delete task in current taskList ? (skip if don`t) (%Title%): "); string answer15 = Console.ReadLine(); if (!answer15.Equals("")) { ToDoTask taskForDelete = MainControl.FindTask(answer15, currentList); if (taskForDelete != null) { MainControl.Delete(taskForDelete); Console.WriteLine("Task with name \"" + answer15 + "\" has been succesfully deleted"); currentUser = UserLab.Get().GetUser(currentUser.Id); // Refresh current user currentList = MainControl.FindList(currentList.Title, UserLab.Get().GetUser(currentUser.Id)); currentTask = MainControl.FindTask(answer15, currentList); } else { Console.WriteLine("Task with name: \"" + answer15 + "\" not found"); } } }
private static void ModifyCurrentTask()//Modify current task { Console.Write("Current title: \"" + currentTask.Title + "\". Input new title: "); string answerTitle = Console.ReadLine(); if (!answerTitle.Equals("")) { currentTask.Title = answerTitle; } Console.Write("Current task: \"" + currentTask.Text + "\". Input new task: "); string answerTask = Console.ReadLine(); if (!answerTask.Equals("")) { currentTask.Text = answerTask; } Console.Write("Current status: \"" + (currentTask.IsCompleted ? "Completed" : "Not completed") + "\". Input new status (+/~): "); string answerCompleted = Console.ReadLine(); if (!answerCompleted.Equals("")) { currentTask.IsCompleted = (answerCompleted.Equals("+") ? true : false); } currentUser = MainControl.Modify(currentTask, currentUser); currentList = MainControl.FindList(currentList.Title, currentUser); currentTask = MainControl.FindTask(currentTask.Title, currentList); // Refresh. Now not useful, but in future can be useful Console.WriteLine("You modified task with name \"" + currentTask.Title + "\"; and id: " + currentTask.Id); }
static private ToDoTask currentTask; // Current task static void Main(string[] args) { int currentMenuLevel = 0; while (true) { switch (currentMenuLevel) { case 0: bool result = false; do { currentList = null; currentTask = null; currentUser = null; Console.Clear(); HeadPartView(); Console.Write("LoginIn[1] or Register[2]: "); string answer = Console.ReadLine(); if (answer.Equals("1")) { result = RegLogAction(false); } else if (answer.Equals("2")) { result = RegLogAction(true); } else { result = false; } }while (!result); currentMenuLevel = 1; break; case 1: do { HeadPartView(); //If currentUser doesn`t have listOfLists. if (currentUser.ListOfLists.Count == 0) { Console.WriteLine("||Info: You don`t have no one TaskList. "); } Console.WriteLine(" =============" + currentMenuLevel + "/4============= "); Console.WriteLine("||Create new taskList.......(1)||"); Console.WriteLine("||See all your taskLists....(2)||"); Console.WriteLine("||Choose some taskList......(3)||"); Console.WriteLine("||Delete some taskList......(4)||"); Console.WriteLine("||.............................||"); Console.WriteLine("||Log out...................(0)||"); Console.WriteLine("||Delete account............(9)||"); Console.WriteLine(" ============================= "); Console.Write("Choose action: "); string answer = Console.ReadLine(); Console.WriteLine(); if (answer.Length == 1 & ((int)answer[0] >= 48) & ((int)answer[0] <= 57)) { switch (Convert.ToInt32(answer)) { case 1: CreateTaskList(); break; case 2: SeeAlltasklists(); break; case 3: currentMenuLevel = ChooseTaskListByName(currentMenuLevel); break; case 4: DeleteTaskListByName(); break; case 0: currentMenuLevel = 0; currentUser = null; break; case 9: currentMenuLevel = DeleteAccount(currentMenuLevel); break; } } else { Console.WriteLine("Not correct format. Use just one number for make a choise."); } ExitPartView(); }while (currentMenuLevel.Equals(1)); break; case 2: do { HeadPartView(); Console.WriteLine(" =============" + currentMenuLevel + "/4============= "); Console.WriteLine("||Rename current list.......(1)||"); Console.WriteLine("||Add task in list..........(2)||"); Console.WriteLine("||See tasks in list.........(3)||"); Console.WriteLine("||Choose task in list.......(4)||"); Console.WriteLine("||Delete some task in task..(5)||"); Console.WriteLine("||Return....................(0)||"); Console.WriteLine(" ============================= "); Console.Write("Choose action: "); string answer = Console.ReadLine(); Console.WriteLine(); if (answer.Length <= 1 & ((int)answer[0] >= 48) & ((int)answer[0] <= 57)) { switch (Convert.ToInt32(answer)) { case 1: RenameCurrentList(); break; case 2: AddTaskInCurrentList(); break; case 3: SeeAllTasksInCurrentList(); break; case 4: currentMenuLevel = ChooseTaskInCurrentList(currentMenuLevel); break; case 5: DeleteTaskInCurrentListByName(); break; case 0: currentMenuLevel = 1; currentList = null; break; } } else { Console.WriteLine("Not correct format. Use just one number for make a choise."); } ExitPartView(); }while (currentMenuLevel.Equals(2)); break; case 3: do { HeadPartView(); Console.WriteLine(" =============" + currentMenuLevel + "/4============= "); Console.WriteLine("||Modify current task.......(1)||"); Console.WriteLine("||See current task..........(2)||"); Console.WriteLine("||Return....................(0)||"); Console.WriteLine(" ============================= "); Console.Write("Choose action: "); string answer = Console.ReadLine(); Console.WriteLine(); if (answer.Length <= 1 & ((int)answer[0] >= 48) & ((int)answer[0] <= 57)) { switch (Convert.ToInt32(answer)) { case 1: ModifyCurrentTask(); break; case 2: SeeCurrentTasks(); break; case 0: currentMenuLevel = 2; currentTask = null; break; } } else { Console.WriteLine("Not correct format. Use just one number for make a choise."); } ExitPartView(); }while (currentMenuLevel.Equals(3)); break; } } }