diff --git a/OliverBooth/Services/BlogService.cs b/OliverBooth/Services/BlogService.cs index bd0d055..0f621f8 100644 --- a/OliverBooth/Services/BlogService.cs +++ b/OliverBooth/Services/BlogService.cs @@ -76,15 +76,30 @@ public sealed class BlogService } /// - /// Attempts to find a blog post by its publication date and slug. + /// Attempts to find a blog post by new ID. + /// + /// The new ID of the post. + /// + /// When this method returns, contains the associated with ID, if the post is found; + /// otherwise, . + /// + /// if the post is found; otherwise, . + public bool TryGetBlogPost(int postId, [NotNullWhen(true)] out BlogPost? post) + { + using BlogContext context = _dbContextFactory.CreateDbContext(); + post = context.BlogPosts.FirstOrDefault(p => p.Id == postId); + return post is not null; + } + + /// + /// Attempts to find a blog post by its legacy WordPress ID. /// /// The WordPress ID of the post. /// - /// When this method returns, contains the associated with the specified publication - /// date and slug, if the post is found; otherwise, . + /// When this method returns, contains the associated with ID, if the post is found; + /// otherwise, . /// /// if the post is found; otherwise, . - /// is . public bool TryGetWordPressBlogPost(int postId, [NotNullWhen(true)] out BlogPost? post) { using BlogContext context = _dbContextFactory.CreateDbContext();