예제 #1
0
        //Remove an item from List-if a task no needed
        public void RemoveItem(ToDoListItem toDoListItem)
        {
            if (toDoListItem is null)
            {
                throw new ArgumentNullException(nameof(toDoListItem));
            }

            items.Remove(toDoListItem);
        }
예제 #2
0
        //Delete finished task from list-permanently
        public void Delete(ToDoListItem toDoListItem)
        {
            if (toDoListItem is null)
            {
                throw new ArgumentNullException(nameof(toDoListItem));
            }

            tasks.Remove(toDoListItem);
        }
예제 #3
0
        //Add item to completed item list
        public void AddToCompleted(ToDoListItem toDoListItem)
        {
            if (toDoListItem is null)
            {
                throw new ArgumentNullException(nameof(toDoListItem));
            }

            if (toDoListItem.IsCompleted == true)
            {
                tasks.Add(toDoListItem);
            }
        }
예제 #4
0
        //add an repeating or reoccuring task to list
        public void AddReOccuringTask(ToDoListItem toDoListItem, RepeatingTask repeatingTask)
        {
            if (toDoListItem is null)
            {
                throw new ArgumentNullException(nameof(toDoListItem));
            }


            if (repeatingTask.IsReOccuring == true)
            {
                items.Add(toDoListItem);// #@ this can be merge with add item of to do list
            }
        }
예제 #5
0
        //Mark a completed item as not finished
        public void MarkAsInComplete(ToDoListItem toDoListItem)
        {
            if (toDoListItem is null)
            {
                throw new ArgumentNullException(nameof(toDoListItem));
            }

            if (toDoListItem.IsCompleted == false)
            {
                tasks.Remove(toDoListItem);     //remove item from completed list -if it is unfinish
                ToDoList toDoList = new ToDoList();
                toDoList.AddItem(toDoListItem); //add that item to todo list again as unfinish task-if a task marked as completed and possible mark as incompleted
            }
        }
예제 #6
0
        //add an repeating task as completed
        public void RepeatCompleted(ToDoListItem toDoListItem, RepeatingTask repeatingTask)
        {
            if (toDoListItem is null)
            {
                throw new ArgumentNullException(nameof(toDoListItem));
            }

            if (toDoListItem.IsCompleted == true)
            {
                tasks.Add(toDoListItem);
            }


            if (repeatingTask.EndTime <= DateTime.Now)
            {
                tasks.Remove(toDoListItem);     //task remove from completed
                ToDoList toDoList = new ToDoList();
                toDoList.AddItem(toDoListItem); //added to todo list again for next routine
            }
        }
예제 #7
0
        //Add a task  as Completed Task which has sub tasks
        public void CompleteSubTask(ToDoListItem toDoListItem, SubTaskToDoList subTaskTo)
        {
            if (toDoListItem is null)
            {
                throw new ArgumentNullException(nameof(toDoListItem));
            }

            if (toDoListItem.IsCompleted == true & subTaskTo.HasSubTask == false)
            {
                tasks.Add(toDoListItem);
            }

            if (subTaskTo.HasSubTask == true)
            {
                foreach (var item in subTaskTo.GetAllSubTasks())
                {
                    if (item.IsCompleted == true)
                    {
                        tasks.Add(subTaskTo);//if every sub task items completed only main task consider as completed task
                    }
                }
            }
        }