Пример #1
0
        private static XRpcStruct CreateBlogStruct(
            BlogPostPart blogPostPart,
            UrlHelper urlHelper)
        {
            var url = urlHelper.AbsoluteAction(() => urlHelper.ItemDisplayUrl(blogPostPart));

            if (blogPostPart.HasDraft()) {
                url = urlHelper.AbsoluteAction("Preview", "Item", new { area = "Contents", id = blogPostPart.ContentItem.Id });
            }

            var blogStruct = new XRpcStruct()
                .Set("postid", blogPostPart.Id)
                .Set("title", HttpUtility.HtmlEncode(blogPostPart.Title))

                .Set("description", blogPostPart.Text)
                .Set("link", url)
                .Set("permaLink", url);

            blogStruct.Set("wp_slug", blogPostPart.As<IAliasAspect>().Path);

            if (blogPostPart.PublishedUtc != null) {
                blogStruct.Set("dateCreated", blogPostPart.PublishedUtc);
                blogStruct.Set("date_created_gmt", blogPostPart.PublishedUtc);
            }

            return blogStruct;
        }