Ejemplo n.º 1
0
        /// <summary>
        /// 获取文章详细内容
        /// </summary>
        /// <param name="aid">文章详细模型</param>
        public ArticleDetailsModel GetOneArticleContentByID(Guid aid)
        {
            IRepository <Article> rep = Factory.Factory <IRepository <Article> > .GetConcrete <Article>();

            IRepository <BlogComment> commentRep = Factory.Factory <IRepository <BlogComment> > .GetConcrete <BlogComment>();


            Article                 article  = null;
            ArticleDetailsModel     target   = null;
            IList <CommentDspModel> comments = null;

            try
            {
                article = rep.GetByKey(aid);
                if (article != null)
                {
                    IList <BlogComment> list = commentRep.FindAll(new Specification <BlogComment>(c => c.TargetId == aid).OrderBy(c => c.CreationDate).Skip(0).Take(10000));
                    if (list != null)
                    {
                        comments = new List <CommentDspModel>();
                        foreach (BlogComment c in list)
                        {
                            CommentDspModel tmp = new CommentDspModel()
                            {
                                AccountID = c.AccountInfo.Id, TargetID = c.TargetId, UserName = c.AccountInfo.UserName, CommentContent = c.Body, CreatedOn = c.CreationDate, CommentID = c.Id
                            };
                            comments.Add(tmp);
                        }
                    }

                    target = new ArticleDetailsModel()
                    {
                        Body         = article.ArticleVO.Body,
                        Title        = article.ArticleVO.Title,
                        CategoryID   = article.CategoryID,
                        CategoryName = article.CategoryName,
                        ClickCount   = article.ArticleVO.ClickCount,
                        CommentCount = article.ArticleVO.CommentCount,
                        CreationDate = article.CreationDate,
                        SourceSite   = article.ArticleVO.SourceSite,
                        SourceUrl    = article.ArticleVO.SourceUrl,
                        UserID       = article.UserID,
                        BriefTitle   = article.ArticleVO.BriefTitle,
                        UserName     = article.UserName,
                        Comments     = comments
                    };
                }
                else
                {
                    return(target);
                }
            }

            catch (Exception error)
            {
                throw new Exception(error.Message);
            }

            return(target);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取分享视频详细内容
        /// </summary>
        /// <param name="aid">分享视频编号</param>
        public ShareThreadDetailsModel GetOneShareThreadContentByID(Guid aid)
        {
            IRepository <ShareThread> rep = Factory.Factory <IRepository <ShareThread> > .GetConcrete <ShareThread>();

            IRepository <BlogComment> commentRep = Factory.Factory <IRepository <BlogComment> > .GetConcrete <BlogComment>();

            ShareThread             sharethread = null;
            ShareThreadDetailsModel target      = null;

            var comments = commentRep.FindAll(new Specification <BlogComment>(c => c.TargetId == aid).OrderBy(c => c.CreationDate).Skip(0).Take(10000));
            IList <CommentDspModel> cmodels = new List <CommentDspModel>();

            foreach (BlogComment c in comments)
            {
                CommentDspModel tmp = new CommentDspModel()
                {
                    AccountID = c.AccountInfo.Id, CommentContent = c.Body, CommentID = c.Id, CreatedOn = c.CreationDate, TargetID = c.TargetId, UserName = c.AccountInfo.UserName
                };
                cmodels.Add(tmp);
            }

            try
            {
                sharethread = rep.GetByKey(aid);

                target = new ShareThreadDetailsModel()
                {
                    RawUrl       = sharethread.RawUrl,
                    Body         = sharethread.Body,
                    PlayUrl      = sharethread.PlayUrl,
                    Subject      = sharethread.Subject,
                    ThumbnailUrl = sharethread.ThumbnailUrl,
                    ShareTime    = sharethread.ShareTime,
                    Comments     = cmodels
                };
            }

            catch (Exception error)
            {
                throw new Exception(error.Message);
            }

            return(target);
        }