Exemplo n.º 1
0
        /// <summary>
        /// 获取文章评论信息
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string GetArticleReviewlist(HttpContext context)
        {
            string           id        = context.Request["articleid"];
            int              pageIndex = int.Parse(context.Request["pageindex"]);
            int              pageSize  = int.Parse(context.Request["pagesize"]);
            ArticleReviewApi apiResult = new ArticleReviewApi();
            StringBuilder    sbWhere   = new StringBuilder();

            sbWhere.AppendFormat(" ReviewID={0}", id);
            apiResult.totalcount = bll.GetCount <ReplyReviewInfo>(sbWhere.ToString());
            List <ReplyReviewInfo> data       = bll.GetLit <BLLJIMP.Model.ReplyReviewInfo>(pageSize, pageIndex, sbWhere.ToString(), " AutoId desc");
            List <ArticleReview>   jsonResult = new List <ArticleReview>();

            foreach (var item in data)
            {
                ArticleReview review = new ArticleReview();
                //目标评论内容
                if (item.PraentId > 0)
                {
                    var targetReply = bll.Get <ReplyReviewInfo>(string.Format("AutoId={0}", item.PraentId)); if (targetReply != null)
                    {
                        review.reply = new ArticleReplyReview();
                        review.reply.reviewcontent = targetReply.ReplyContent;
                        review.reply.nickname      = targetReply.UserName;
                    }
                }

                //目标评论内容
                var userInfo = bllUser.GetUserInfo(item.UserId);
                if (userInfo != null)
                {
                    review.headimg = userInfo.WXHeadimgurlLocal;
                }
                review.id            = item.AutoId;
                review.nickname      = item.UserName;
                review.time          = bll.GetTimeStamp(item.InsertDate);
                review.reviewcontent = item.ReplyContent;
                if ((bll.IsLogin) && (item.UserId.Equals(currentUserInfo.UserID)))
                {
                    review.deleteflag = true;
                }


                jsonResult.Add(review);
            }
            apiResult.list = jsonResult;
            return(Common.JSONHelper.ObjectToJson(apiResult));
        }