Example #1
0
        private static BlogPost GetBlogPost(BloggerPostData post, BlogSetting blogSetting)
        {
            var blogPost = BloggerDataConverter.ConvertPost(post);
            blogPost.BlogKey = blogSetting.BlogKey;

            return blogPost;
        }
        public static BlogPost ConvertPost(BloggerPostData post)
        {
            if (post == null)
            {
                throw new ArgumentNullException(nameof(post));
            }

            var author = new BlogAuthor
                             {
                                 ImageUrl = post.Author?.Image?.Url,
                                 Name = post.Author?.DisplayName,
                                 SourceId = post.Author?.Id,
                                 Url = post.Author?.Url
                             };

            // Properties set by BlogSyncServiceUpdatePostsHelper: BlavenId, UrlSlug
            var blogPost = new BlogPost
                               {
                                   BlogAuthor = author,
                                   Content = post.Content,
                                   Hash = GetBlogPostHash(post),
                                   PublishedAt = post.Published,
                                   SourceId = post.Id,
                                   SourceUrl = post.Url,
                                   BlogPostTags =
                                       post.Labels?.Select(x => new BlogPostTag(x)).ToList() ?? new List<BlogPostTag>(),
                                   Title = post.Title,
                                   UpdatedAt = post.Updated
                               };
            return blogPost;
        }
        private static string GetBlogPostHash(BloggerPostData post)
        {
            if (post == null)
            {
                throw new ArgumentNullException(nameof(post));
            }

            string hash = post.Updated?.ToUniversalTime().ToString("o") ?? post.ETag;
            return hash;
        }