Esempio n. 1
0
        public void LeaveProject(int projectId)
        {
            var record = _projectUserRepository.GetByPredicate(i => i.ProjectId == projectId &&
                                                               i.UserId == _userId).First();

            _projectUserRepository.Remove(record);

            // Project still has users.
            if (_projectUserRepository.GetByPredicate(i => i.ProjectId == projectId).Any())
            {
                return;
            }

            // Deleting all tasks, that belong to this project.
            var projectItems = _itemRepository.GetByPredicate(i => i.ProjectId == projectId).ToList();

            foreach (var i in projectItems)
            {
                // Deleting all tags, that has this task.
                if (!_tagService.RemoveTagsFromTask(i.Id) ||
                    !_tagService.RemoveSharedTags(projectId))
                {
                    MessageBox.Show("Can't delete tags from a task");
                    return;
                }

                _itemRepository.Remove(i);
            }

            _projectRepository.Remove(_projectRepository.GetByPredicate(i => i.Id == projectId).First());
        }
Esempio n. 2
0
        public bool Remove(ToDoItemModel item)
        {
            var foundItem = _repository.GetByPredicate(i => i.Id == item.Id).First();

            return(_tagService.RemoveTagsFromTask(foundItem.Id) && _repository.Remove(foundItem));
        }