예제 #1
0
        static public User Add(string title, string text, ToDoTaskList taskList, User user) // Add task into tasklist III stage
        {
            ToDoTask task = new ToDoTask(title, text, taskList.Id);

            UserLab.Get().Add(task);
            return(UserLab.Get().GetUser(user.Id)); // Pull from singleton
        }
예제 #2
0
 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");
         }
     }
 }
예제 #3
0
        static public User Add(string title, User user) // II stage
        {
            ToDoTaskList toDoTaskList = new ToDoTaskList(user.Id, title);

            UserLab.Get().Add(toDoTaskList);
            return(UserLab.Get().GetUser(user.Id));
        }
예제 #4
0
        public static ToDoTaskList CreateFromId(string ID)
        {
            ToDoTaskList newToDoTaskList = new ToDoTaskList()
            {
                Id = ID
            };

            return(newToDoTaskList);
        }
예제 #5
0
 static public ToDoTask FindTask(string title, ToDoTaskList taskList)
 {
     foreach (var item in taskList.Tasks)
     {
         if (item.Title.Equals(title))
         {
             return(item);
         }
     }
     return(null);
 }
예제 #6
0
        static public string GetAllTaskInList(ToDoTaskList taskList, User user) //Return list of titles All Tasks in list
        {
            StringBuilder   result = new StringBuilder();
            List <ToDoTask> list   = FindList(taskList.Title, user).Tasks; // Debug. Get  current

            foreach (var item in list)
            {
                result.Append("Title: \"" + item.Title + "\" is " + (item.IsCompleted ? "Completed" : "Not completed") + "; Text: \"" + item.Text + "\" id: " + item.Id + "\n");
            }
            return(result.ToString());
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
        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 + "\"");
            }
        }
예제 #9
0
 public MainWindow()
 {
     InitializeComponent();
     _taskList    = new ToDoTaskList();
     _todoMeneger = new ToDoListMeneger();
     _todoMeneger.CreateDBAndTAbleIfNotExist();
     _taskList = _todoMeneger.ReadFromBase(_taskList);
     for (int i = 0; i < _taskList.Count; i++)
     {
         if (listBoxToDoListBox.Height < 250)
         {
             listBoxToDoListBox.Height += 51;
         }
         listBoxToDoListBox.Items.Add(new TaskItam(_taskList[i].Value, _taskList[i].Completed));
     }
 }
예제 #10
0
 private static int ChooseTaskListByName(int currentMenuLevel) //Choose some taskList by name
 {
     Console.Write("Choose some taskList? (%Title%): "); string answer13 = Console.ReadLine();
     if (!answer13.Equals(""))
     {
         currentList = MainControl.FindList(answer13, currentUser);
         if (currentList != null)
         {
             Console.WriteLine("Choosen list has name: \"" + currentList.Title + "\"; and id: " + currentList.Id);
             currentMenuLevel = 2;
         }
         else
         {
             Console.WriteLine("List with name: \"" + answer13 + "\" not found");
         }
     }
     return(currentMenuLevel);
 }
예제 #11
0
        public async Task <List <ToDoTaskList> > GetAllToDoTaskListsAsync()
        {
            // Get all To Do lists.

            Uri    URL;
            string idAttributeName;
            string displayNameAttributeName;

            URL                      = new Uri($"https://graph.microsoft.com/v1.0/me/todo/lists");
            idAttributeName          = "id";
            displayNameAttributeName = "displayName";

            string stringResponse = "";

            try
            {
                stringResponse = await SendGetRequestAsync(URL);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            // Convert JSON response.

            var jsonResponse  = (JObject)JsonConvert.DeserializeObject(stringResponse);
            var toDoTaskLists = (JArray)jsonResponse.GetValue("value");

            List <ToDoTaskList> result = new List <ToDoTaskList>();

            foreach (var folder in toDoTaskLists)
            {
                string id          = folder.Value <string>(idAttributeName);
                string displayName = folder.Value <string>(displayNameAttributeName);

                ToDoTaskList newToDoTaskList = ToDoTaskList.CreateFromId(id);
                newToDoTaskList.DisplayName = displayName;

                result.Add(newToDoTaskList);
            }

            return(result);
        }
예제 #12
0
 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");
         }
     }
 }
예제 #13
0
        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);
        }
예제 #14
0
 static public void Delete(ToDoTaskList list) // Delete founded list
 {
     UserLab.Get().Remove(list);
 }
예제 #15
0
 static public User Modify(ToDoTaskList list, User user) // Modify users one Task list
 {
     UserLab.Get().Modify(list);
     return(UserLab.Get().GetUser(user.Id));
 }
예제 #16
0
        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;
                }
            }
        }