Example #1
0
        public void SetTodos(ITodo[] todos)
        {
            if (todos == null
                || todos.Any(x => x.Id == null || ((ObjectId)x.Id).Equals(ObjectId.Empty))) {
                throw new ArgumentNullException(
                    "todos",
                    "Cannot add new tasks with no or default ID, please use the AddTodo method first.");
            }

            if (
                !todos.Any(
                    x =>
                        ((ObjectId)x.UserId).Equals((ObjectId)Id)
                            || ((ObjectId)x.UserId).Equals(ObjectId.Empty)))
                throw new ArgumentException("Cannot add tasks that belong to another user");

            _user.SetTodos(todos);
        }
Example #2
0
        public void SetTodos(ITodo[] todos)
        {
            if (todos == null
                || todos.Any(x => x.Id == null)) {
                throw new ArgumentNullException(
                    "todos",
                    "Cannot add new tasks with no or default ID, please use the AddTodo method first.");
            }

            if (!todos.Any(x => x.UserId.Equals(Id)))
                throw new ArgumentException("Cannot add tasks that belong to another user");

            RemoveAllTodos();
            AddTodos(todos);
            Timestamp = DateTime.Now;
        }