示例#1
0
 public async Task SetStatusAsync(List <int> commentIds, CommentStatus status)
 {
     await _repository.UpdateAsync(Q
                                   .Set(nameof(Comment.Status), status.GetValue())
                                   .WhereIn(nameof(Comment.Id), commentIds)
                                   );
 }
示例#2
0
        public async Task <(int Total, List <Comment>)> GetCommentsAsync(int siteId, int channelId, int contentId, CommentStatus status, string keyword, int page, int pageSize)
        {
            if (page == 0)
            {
                page = 1;
            }

            var q = Q
                    .Where(nameof(Comment.SiteId), siteId)
                    .OrderByDesc(nameof(Comment.Id));

            if (channelId > 0)
            {
                q.Where(nameof(Comment.ChannelId), channelId);
            }
            if (contentId > 0)
            {
                q.Where(nameof(Comment.ContentId), contentId);
            }

            if (status != CommentStatus.All)
            {
                q.Where(nameof(Comment.Status), status.GetValue());
            }

            if (!string.IsNullOrEmpty(keyword))
            {
                q.WhereLike(nameof(Comment.Content), $"%{keyword}%");
                //q.Where(query => query
                //    .WhereLike(nameof(Comment.Content), $"%{keyword}%")
                //    .OrWhereLike(ExtendValues, $"%{keyword}%")
                //);
            }

            var count = await _repository.CountAsync(q);

            var list = await _repository.GetAllAsync(q.ForPage(page, pageSize));

            return(count, list);
        }