Esempio n. 1
0
        public List <CommentNReplies> GetList(int postId, string postType, string openId = "")
        {
            List <CommentNReplies> comments = new List <CommentNReplies>();

            try
            {
                var dao = new CommentsDao(mysqlConnection);
                comments.AddRange(dao.GetList(postId, postType));

                if (!string.IsNullOrEmpty(openId))
                {
                    comments.AddRange(dao.GetPendingList(postId, postType, openId)); //发表评论的人可以看到自己发表但未审核的评论
                }

                //读取作者对评论的回复
                comments.ForEach(comment =>
                {
                    comment.Replies = dao.GetAuthorReplies(comment.comment_id);
                });
            }
            catch (Exception ex)
            {
                logger.Error("获取评论失败", ex);
            }

            return(comments.OrderByDescending(comm => comm.createdAt).ToList());
        }
Esempio n. 2
0
        public List <CommentNReplies> GetListForMyProfile(int postId, string postType)
        {
            List <CommentNReplies> comments = new List <CommentNReplies>();

            try
            {
                var dao = new CommentsDao(mysqlConnection);
                comments.AddRange(dao.GetListForMyProfile(postId, postType));

                //读取作者对评论的回复
                comments.ForEach(comment =>
                {
                    comment.Replies = dao.GetAuthorReplies(comment.comment_id);
                });
            }
            catch (Exception ex)
            {
                logger.Error("获取评论失败", ex);
            }

            return(comments.OrderByDescending(comm => comm.createdAt).ToList());
        }