public string GetUrlSlug(BlogPost blogPost) { if (blogPost == null) { throw new ArgumentNullException(nameof(blogPost)); } return blogPost.UrlSlug; }
public string GetUrlSlug(BlogPost blogPost) { if (blogPost == null) { throw new ArgumentNullException(nameof(blogPost)); } if (string.IsNullOrWhiteSpace(blogPost.Title)) { string message = $"{nameof(BlogPost)} cannot have an empty or null {nameof(BlogPost.Title)}."; throw new ArgumentOutOfRangeException(nameof(blogPost), message); } string slug = Create(blogPost.Title); return slug; }
private static XElement GetPostXElement(BlogPost post, bool includeBlogContent) { var itemElements = new[] { new XElement("title", post.Title), new XElement("link", post.OriginalBloggerUrl), new XElement("pubDate", post.Published.ToString("r")), new XElement("author", post.Author.Name), }; if(includeBlogContent) { itemElements = itemElements.Concat(new[] { new XElement("description", post.Content), }).ToArray(); } return new XElement("item", itemElements ); }