using System.Diagnostics.CodeAnalysis; using OliverBooth.Blog.Data; namespace OliverBooth.Blog.Services; /// /// Represents a service for managing blog posts. /// public interface IBlogPostService { /// /// Returns a collection of all blog posts. /// /// The maximum number of posts to return. A value of -1 returns all posts. /// A collection of all blog posts. /// /// This method may slow down execution if there are a large number of blog posts being requested. It is /// recommended to use instead. /// IReadOnlyList GetAllBlogPosts(int limit = -1); /// /// Returns a collection of blog posts from the specified page, optionally limiting the number of posts /// returned per page. /// /// The zero-based index of the page to return. /// The maximum number of posts to return per page. /// A collection of blog posts. IReadOnlyList GetBlogPosts(int page, int pageSize = 10); /// /// Renders the excerpt of the specified blog post. /// /// The blog post whose excerpt to render. /// /// When this method returns, contains if the excerpt was trimmed; otherwise, /// . /// /// The rendered HTML of the blog post's excerpt. string RenderExcerpt(IBlogPost post, out bool wasTrimmed); /// /// Renders the body of the specified blog post. /// /// The blog post to render. /// The rendered HTML of the blog post. string RenderPost(IBlogPost post); /// /// Attempts to find a blog post with the specified ID. /// /// The ID of the blog post to find. /// /// When this method returns, contains the blog post with the specified ID, if the blog post is found; /// otherwise, . /// /// /// if a blog post with the specified ID is found; otherwise, . /// bool TryGetPost(Guid id, [NotNullWhen(true)] out IBlogPost? post); /// /// Attempts to find a blog post with the specified WordPress ID. /// /// The ID of the blog post to find. /// /// When this method returns, contains the blog post with the specified WordPress ID, if the blog post is found; /// otherwise, . /// /// /// if a blog post with the specified WordPress ID is found; otherwise, /// . /// bool TryGetPost(int id, [NotNullWhen(true)] out IBlogPost? post); /// /// Attempts to find a blog post with the specified publish date and URL slug. /// /// The date the blog post was published. /// The URL slug of the blog post to find. /// /// When this method returns, contains the blog post with the specified publish date and URL slug, if the blog /// post is found; otherwise, . /// /// /// if a blog post with the specified publish date and URL slug is found; otherwise, /// . /// /// is . bool TryGetPost(DateOnly publishDate, string slug, [NotNullWhen(true)] out IBlogPost? post); }