Beispiel #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sfContent">The sf content.</param>
        public BlogPostModel(BlogPost sfContent)
            : base(sfContent)
        {
            if (sfContent != null)
            {
                Content = sfContent.Content;
                Summary = sfContent.Summary;
                Status  = sfContent.Status;
                Slug    = sfContent.UrlName;
                Active  = sfContent.Status == ContentLifecycleStatus.Live &&
                          sfContent.Visible;

                //GET PARENT BLOG
                Parent = new BlogModel(sfContent.Parent);

                //CONSTRUCT URL BASED ON PARENT BLOG
                Url = sfContent.GetFullUrl(sfContent.DefaultPageId);
                if (sfContent.Parent.DefaultPageId.HasValue)
                {
                    Url = Parent.Url + Url;
                }

                //POPULATE TAXONOMIES TO LIST
                Categories = sfContent.GetTaxa("Category");
                Tags       = sfContent.GetTaxa("Tags");

                //CALCULATE COMMENTS
                CommentsCount = BlogsManager.GetManager().GetComments()
                                .Count(c => c.CommentedItemID == sfContent.Id &&
                                       c.Status == ContentLifecycleStatus.Master);

                //CUSTOM PROPERTIES
                if (sfContent.DoesFieldExist("Image"))
                {
                    Image = sfContent.GetValue <string>("Image");
                }

                // Store original content
                OriginalContent = sfContent;
            }
        }