using System.Diagnostics.CodeAnalysis; using OliverBooth.Common.Data; using OliverBooth.Common.Data.Blog; namespace OliverBooth.Common.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 the total number of blog posts. /// /// The post visibility filter. /// The tags of the posts to return. /// The total number of blog posts. int GetBlogPostCount(Visibility visibility = Visibility.None, string[]? tags = null); /// /// 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. /// The tags of the posts to return. /// A collection of blog posts. IReadOnlyList GetBlogPosts(int page, int pageSize = 10, string[]? tags = null); /// /// Returns the number of legacy comments for the specified post. /// /// The post whose legacy comments to count. /// The total number of legacy comments. int GetLegacyCommentCount(IBlogPost post); /// /// Returns the collection of legacy comments for the specified post. /// /// The post whose legacy comments to retrieve. /// A read-only view of the legacy comments. IReadOnlyList GetLegacyComments(IBlogPost post); /// /// Returns the collection of replies to the specified legacy comment. /// /// The comment whose replies to retrieve. /// A read-only view of the replies. IReadOnlyList GetLegacyReplies(ILegacyComment comment); /// /// Returns the next blog post from the specified blog post. /// /// The blog post whose next post to return. /// The next blog post from the specified blog post. IBlogPost? GetNextPost(IBlogPost blogPost); /// /// Returns the number of pages needed to render all blog posts, using the specified as an /// indicator of how many posts are allowed per page. /// /// The page size. Defaults to 10. /// The post visibility filter. /// The tags of the posts to return. /// The page count. int GetPageCount(int pageSize = 10, Visibility visibility = Visibility.None, string[]? tags = null); /// /// Returns the previous blog post from the specified blog post. /// /// The blog post whose previous post to return. /// The previous blog post from the specified blog post. IBlogPost? GetPreviousPost(IBlogPost blogPost); /// /// 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); }