Exemplo n.º 1
0
 public UnifyResponseDto DeleteBook(int id)
 {
     _bookRepository.Delete(new Book {
         Id = id
     });
     return(UnifyResponseDto.Success());
 }
Exemplo n.º 2
0
 public ResultDto DeleteArticle(int id)
 {
     _articleRepository.Delete(new Article {
         Id = id
     });
     return(ResultDto.Success());
 }
Exemplo n.º 3
0
 public UnifyResponseDto DeletePoem(long id)
 {
     _poemRepository.Delete(new LinPoem {
         Id = id
     });
     return(UnifyResponseDto.Success());
 }
Exemplo n.º 4
0
        public void Put(Guid id, CreateUpdateChannelDto updateChannel)
        {
            Channel channel = _channelRepository.Select.Where(r => r.Id == id).ToOne();

            if (channel == null)
            {
                throw new LinCmsException("该数据不存在");
            }

            bool exist = _channelRepository.Select.Any(r => r.ChannelName == updateChannel.ChannelName && r.Id != id && r.ChannelCode == updateChannel.ChannelCode);

            if (exist)
            {
                throw new LinCmsException($"技术频道[{updateChannel.ChannelName}]已存在");
            }

            _mapper.Map(updateChannel, channel);

            var channelTagLists = new List <ChannelTag>();

            updateChannel.TagIds?.ForEach(r => { channelTagLists.Add(new ChannelTag(id, r)); });

            _channelTagRepository.Delete(r => r.ChannelId == id);
            _channelRepository.Update(channel);
            _channelTagRepository.Insert(channelTagLists);
        }
 public ResultDto DeletePoem(int id)
 {
     _poemRepository.Delete(new LinPoem {
         Id = id
     });
     return(ResultDto.Success());
 }
Exemplo n.º 6
0
 public UnifyResponseDto DeleteTag(Guid id)
 {
     _tagRepository.Delete(new Tag {
         Id = id
     });
     return(UnifyResponseDto.Success());
 }
 public ResultDto DeleteTag(Guid id)
 {
     _tagRepository.Delete(new Tag {
         Id = id
     });
     return(ResultDto.Success());
 }
 public ResultDto DeleteBaseItem(int id)
 {
     _baseItemRepository.Delete(new BaseItem {
         Id = id
     });
     return(ResultDto.Success());
 }
 public ResultDto DeleteBaseType(int id)
 {
     _baseTypeRepository.Delete(new BaseType {
         Id = id
     });
     return(ResultDto.Success());
 }
Exemplo n.º 10
0
 public ResultDto DeleteBook(int id)
 {
     _bookRepository.Delete(new Book {
         Id = id
     });
     return(ResultDto.Success());
 }
 public UnifyResponseDto DeleteBaseItem(int id)
 {
     _baseItemRepository.Delete(new BaseItem {
         Id = id
     });
     return(UnifyResponseDto.Success());
 }
        public void Delete(long subscribeUserId)
        {
            bool any = _userSubscribeRepository.Select.Any(r => r.CreateUserId == _currentUser.Id && r.SubscribeUserId == subscribeUserId);

            if (!any)
            {
                throw new LinCmsException("已取消关注");
            }
            _userSubscribeRepository.Delete(r => r.SubscribeUserId == subscribeUserId && r.CreateUserId == _currentUser.Id);
        }
Exemplo n.º 13
0
        public void Delete(Guid tagId)
        {
            bool any = _userTagRepository.Select.Any(r => r.CreateUserId == _currentUser.Id && r.TagId == tagId);

            if (!any)
            {
                throw new LinCmsException("已取消关注");
            }
            _userTagRepository.Delete(r => r.TagId == tagId && r.CreateUserId == _currentUser.Id);
            _tagService.UpdateSubscribersCount(tagId, -1);
        }
Exemplo n.º 14
0
        public void Delete(Guid id)
        {
            Article article = _articleRepository.Select.Where(r => r.Id == id).IncludeMany(r => r.Tags).ToOne();

            _classifyService.UpdateArticleCount(article.ClassifyId, 1);
            article.Tags.ToList()
            .ForEach(u =>
            {
                _tagService.UpdateArticleCount(u.Id, -1);
            });

            _articleRepository.Delete(new Article {
                Id = id
            });
            _tagArticleRepository.Delete(r => r.ArticleId == id);
            _commentBaseRepository.Delete(r => r.SubjectId == id);
            _userLikeRepository.Delete(r => r.SubjectId == id);
        }
        public ResultDto Post([FromBody] CreateUpdateUserLikeDto createUpdateUserLike)
        {
            Expression <Func <UserLike, bool> > predicate = r => r.SubjectId == createUpdateUserLike.SubjectId && r.CreateUserId == _currentUser.Id;

            bool exist = _userLikeRepository.Select.Any(predicate);

            if (exist)
            {
                _userLikeRepository.Delete(predicate);

                switch (createUpdateUserLike.SubjectType)
                {
                case 1:
                    _articleAuditBaseRepository.UpdateDiy.Set(r => r.LikesQuantity - 1).Where(r => r.Id == createUpdateUserLike.SubjectId).ExecuteAffrows();
                    break;

                case 2:
                    _commentRepository.UpdateDiy.Set(r => r.LikesQuantity - 1).Where(r => r.Id == createUpdateUserLike.SubjectId).ExecuteAffrows();
                    break;
                }

                return(ResultDto.Success("取消点赞成功"));
            }

            UserLike userLike = _mapper.Map <UserLike>(createUpdateUserLike);

            _userLikeRepository.Insert(userLike);

            switch (createUpdateUserLike.SubjectType)
            {
            case 1:
                _articleAuditBaseRepository.UpdateDiy.Set(r => r.LikesQuantity + 1).Where(r => r.Id == createUpdateUserLike.SubjectId).ExecuteAffrows();
                break;

            case 2:
                _commentRepository.UpdateDiy.Set(r => r.LikesQuantity + 1).Where(r => r.Id == createUpdateUserLike.SubjectId).ExecuteAffrows();
                break;
            }

            return(ResultDto.Success("点赞成功"));
        }
Exemplo n.º 16
0
        public ResultDto Post([FromBody] CreateUpdateUserLikeDto createUpdateUserLike)
        {
            Expression <Func <UserLike, bool> > predicate = r => r.SubjectId == createUpdateUserLike.SubjectId && r.CreateUserId == _currentUser.Id;

            bool exist = _userLikeRepository.Select.Any(predicate);

            if (exist)
            {
                _userLikeRepository.Delete(predicate);

                switch (createUpdateUserLike.SubjectType)
                {
                case 1:
                    this.UpdateArticleLike(createUpdateUserLike.SubjectId, -1);
                    break;

                case 2:
                    this.UpdateCommentLike(createUpdateUserLike.SubjectId, -1);
                    break;
                }

                return(ResultDto.Success("取消点赞成功"));
            }

            UserLike userLike = _mapper.Map <UserLike>(createUpdateUserLike);

            _userLikeRepository.Insert(userLike);

            switch (createUpdateUserLike.SubjectType)
            {
            case 1:
                this.UpdateArticleLike(createUpdateUserLike.SubjectId, 1);
                break;

            case 2:
                this.UpdateCommentLike(createUpdateUserLike.SubjectId, 1);
                break;
            }

            return(ResultDto.Success("点赞成功"));
        }
        public UnifyResponseDto Create([FromBody] CreateUpdateUserLikeDto createUpdateUserLike)
        {
            Expression <Func <UserLike, bool> > predicate = r =>
                                                            r.SubjectId == createUpdateUserLike.SubjectId && r.CreateUserId == _currentUser.Id;

            bool exist = _userLikeRepository.Select.Any(predicate);
            int  increaseLikeQuantity = 1;

            if (exist)
            {
                increaseLikeQuantity = -1;
                _userLikeRepository.Delete(predicate);
            }

            switch (createUpdateUserLike.SubjectType)
            {
            case UserLikeSubjectType.UserLikeArticle:
                this.UpdateArticleLike(createUpdateUserLike.SubjectId, increaseLikeQuantity);
                break;

            case UserLikeSubjectType.UserLikeComment:
                this.UpdateCommentLike(createUpdateUserLike.SubjectId, increaseLikeQuantity);
                break;
            }

            if (exist)
            {
                return(UnifyResponseDto.Success("取消点赞成功"));
            }

            UserLike userLike = _mapper.Map <UserLike>(createUpdateUserLike);

            _userLikeRepository.Insert(userLike);

            this.PublishUserLikeNotification(createUpdateUserLike);

            return(UnifyResponseDto.Success("点赞成功"));
        }
Exemplo n.º 18
0
 public void Delete(Guid id)
 {
     _channelRepository.Delete(new Channel {
         Id = id
     });
 }
Exemplo n.º 19
0
 public void Delete(int id)
 {
     _userRepository.Delete(r => r.Id == id);
 }