public async Task<BlogMeta> GetBlogMeta(BlogKey blogKey = null) { var ensuredBlogKey = this.blogSettings.GetEnsuredBlogKey(blogKey); var meta = await this.repository.GetBlogMeta(ensuredBlogKey); return meta; }
public async Task<BlogPost> GetPostBySourceId(string sourceId, BlogKey blogKey = null) { if (sourceId == null) { throw new ArgumentNullException(nameof(sourceId)); } var ensuredBlogKey = this.blogSettings.GetEnsuredBlogKey(blogKey); var post = await this.repository.GetPostBySourceId(ensuredBlogKey, sourceId); return post; }
public BlogSetting(BlogKey blogKey, string id = null, string name = null) { if (blogKey == null) { throw new ArgumentNullException(nameof(blogKey)); } if (!blogKey.HasValue) { throw new ArgumentOutOfRangeException(nameof(blogKey), $"{nameof(Blaven.BlogKey)} must have a value."); } this.BlogKey = blogKey.Value; this.Id = id; this.Name = name; }
public BlogKey GetEnsuredBlogKey(BlogKey blogKey) { if (blogKey != null) { return blogKey; } string blogSettingsBlogKey = this.BlogKeys.FirstOrDefault(); if (blogSettingsBlogKey == null) { string message = $"No default item found in {nameof(this.BlogKeys)}."; throw new KeyNotFoundException(message); } return blogSettingsBlogKey.ToLowerInvariant(); }
public BlogSetting GetBlogSetting(BlogKey blogKey) { if (blogKey == null) { throw new ArgumentNullException(nameof(blogKey)); } if (!blogKey.HasValue) { throw new ArgumentOutOfRangeException(nameof(blogKey), $"{nameof(BlogKey)} must have a value."); } var blogSetting = this.blogSettings.FirstOrDefault(x => x.BlogKey.Equals(blogKey.Value, StringComparison.OrdinalIgnoreCase)); if (blogSetting == null) { string message = $"Settings did not contain any item with key '{blogKey.Value}'."; throw new KeyNotFoundException(message); } return blogSetting; }