Пример #1
0
        public TodoChangeMessage DeleteTodo(string id)
        {
            var result = new TodoChangeMessage();
            var todo   = todoDictionary[id];

            if (todo.Parent != null)
            {
                var oldParent = todo.Parent;
                oldParent.DeleteChild(todo);
                result.Upsert = result.Upsert.Concat(new[] { TodoConvert.ConvertSingle(oldParent) });
            }
            else
            {
                topTodo.Remove(todo);
            }
            if (todo.HasChildren)
            {
                foreach (var children in todo.Children)
                {
                    result.Merge(DeleteTodoWithoutParent(children.Id));
                }
            }
            result.Delete = result.Delete.Concat(new[] { TodoConvert.ConvertSingle(todo) });
            todoDictionary.Remove(id);

            return(result);
        }
Пример #2
0
        public TodoChangeMessage DeleteTodo(IEnumerable <TodoData> todo)
        {
            var result = new TodoChangeMessage();

            foreach (var t in todo)
            {
                result.Merge(DeleteTodo(t.Id));
            }
            return(result);
        }
Пример #3
0
        public TodoChangeMessage UpsertTodoRange(IEnumerable <TodoData> data)
        {
            var result = new TodoChangeMessage();

            foreach (var todo in data)
            {
                result.Merge(UpsertTodo(todo));
            }
            return(result);
        }
Пример #4
0
        private TodoChangeMessage DeleteTodoWithoutParent(string id)
        {
            var result = new TodoChangeMessage();

            var todo = todoDictionary[id];

            if (todo.HasChildren)
            {
                foreach (var children in todo.Children)
                {
                    result.Merge(DeleteTodoWithoutParent(children.Id));
                }
            }
            result.Delete = result.Delete.Concat(new[] { TodoConvert.ConvertSingle(todo) });
            todoDictionary.Remove(id);

            return(result);
        }