fix: add missing lookup
This commit is contained in:
parent
9de1a84446
commit
56a8ba7368
@ -76,15 +76,30 @@ public sealed class BlogService
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to find a blog post by its publication date and slug.
|
||||
/// Attempts to find a blog post by new ID.
|
||||
/// </summary>
|
||||
/// <param name="postId">The new ID of the post.</param>
|
||||
/// <param name="post">
|
||||
/// When this method returns, contains the <see cref="BlogPost" /> associated with ID, if the post is found;
|
||||
/// otherwise, <see langword="null" />.
|
||||
/// </param>
|
||||
/// <returns><see langword="true" /> if the post is found; otherwise, <see langword="false" />.</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to find a blog post by its legacy WordPress ID.
|
||||
/// </summary>
|
||||
/// <param name="postId">The WordPress ID of the post.</param>
|
||||
/// <param name="post">
|
||||
/// When this method returns, contains the <see cref="BlogPost" /> associated with the specified publication
|
||||
/// date and slug, if the post is found; otherwise, <see langword="null" />.
|
||||
/// When this method returns, contains the <see cref="BlogPost" /> associated with ID, if the post is found;
|
||||
/// otherwise, <see langword="null" />.
|
||||
/// </param>
|
||||
/// <returns><see langword="true" /> if the post is found; otherwise, <see langword="false" />.</returns>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="slug" /> is <see langword="null" />.</exception>
|
||||
public bool TryGetWordPressBlogPost(int postId, [NotNullWhen(true)] out BlogPost? post)
|
||||
{
|
||||
using BlogContext context = _dbContextFactory.CreateDbContext();
|
||||
|
Loading…
Reference in New Issue
Block a user