//add an item to todo list
        public void AddItem(SubTaskToDoList subTaskToDo)
        {
            if (subTaskToDo is null)
            {
                throw new ArgumentNullException(nameof(subTaskToDo));
            }

            subTasks.Add(subTaskToDo);
        }
Exemplo n.º 2
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
                    }
                }
            }
        }