示例#1
0
        public async Task SaveBlogMeta(BlogSetting blogSetting, BlogMeta blogMeta)
        {
            if (blogSetting == null)
            {
                throw new ArgumentNullException(nameof(blogSetting));
            }
            if (blogMeta == null)
            {
                throw new ArgumentNullException(nameof(blogMeta));
            }

            using (var session = this.DocumentStore.OpenAsyncSession())
            {
                string blogMetaId = RavenDbIdConventions.GetBlogMetaId(blogSetting.BlogKey);

                var existingMeta = await session.LoadAsync<BlogMeta>(blogMetaId);
                if (existingMeta == null)
                {
                    existingMeta = new BlogMeta { BlogKey = blogSetting.BlogKey };
                    await session.StoreAsync(existingMeta);
                }

                existingMeta.Description = blogMeta.Description;
                existingMeta.Name = blogMeta.Name;
                existingMeta.PublishedAt = blogMeta.PublishedAt;
                existingMeta.SourceId = blogMeta.SourceId;
                existingMeta.UpdatedAt = blogMeta.UpdatedAt;
                existingMeta.Url = blogMeta.Url;

                await session.SaveChangesAsync();
            }
        }
        public async Task SaveBlogMeta(BlogSetting blogSetting, BlogMeta blogMeta)
        {
            if (blogSetting == null)
            {
                throw new ArgumentNullException(nameof(blogSetting));
            }
            if (blogMeta == null)
            {
                throw new ArgumentNullException(nameof(blogMeta));
            }

            var existingMeta =
                await
                    this.DbContext.BlogMetas.SingleOrDefaultLocalOrSourceAsync(
                        x => x.BlogKey.Equals(blogSetting.BlogKey, StringComparison.OrdinalIgnoreCase));

            if (existingMeta == null)
            {
                existingMeta = new BlogMeta { BlogKey = blogSetting.BlogKey };
                await this.DbContext.BlogMetas.AddAsync(existingMeta);
            }

            existingMeta.Description = blogMeta.Description;
            existingMeta.Name = blogMeta.Name;
            existingMeta.PublishedAt = blogMeta.PublishedAt;
            existingMeta.SourceId = blogMeta.SourceId;
            existingMeta.UpdatedAt = blogMeta.UpdatedAt;
            existingMeta.Url = blogMeta.Url;

            await this.DbContext.SaveChangesAsync();
        }
示例#3
0
 public static BlogMeta Create(string blogKey = null)
 {
     var meta = new BlogMeta
                    {
                        BlogKey = blogKey ?? BlogKey,
                        Description = BlogMetaDescription,
                        Name = BlogMetaName,
                        PublishedAt = BlogMetaPublishedAt,
                        SourceId = BlogMetaSourceId,
                        UpdatedAt = BlogMetaUpdatedAt,
                        Url = "http://testurl.com/testar/test.html"
                    };
     return meta;
 }
示例#4
0
        public static BlogMeta ConvertMeta(BloggerBlogData blog)
        {
            if (blog == null)
            {
                throw new ArgumentNullException(nameof(blog));
            }

            var blogMeta = new BlogMeta
                               {
                                   Description = blog.Description,
                                   Name = blog.Name,
                                   PublishedAt = blog.Published,
                                   SourceId = blog.Id,
                                   UpdatedAt = blog.Updated,
                                   Url = blog.Url
                               };
            return blogMeta;
        }
示例#5
0
        public Task SaveBlogMeta(BlogSetting blogSetting, BlogMeta blogMeta)
        {
            this.OnSaveBlogMetaRun?.Invoke(this, blogSetting.BlogKey);

            return Task.CompletedTask;
        }
示例#6
0
 internal void OnDataUpdated(BlogMeta blogMeta, BlogSyncPostsChangeSet changeSet)
 {
     this.BlogMeta = blogMeta;
     this.BlogPostsChanges = changeSet;
 }