Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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
            }
        }
Ejemplo n.º 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
            }
        }
Ejemplo n.º 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
            }
        }
Ejemplo n.º 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
                    }
                }
            }
        }