fix: add missing lookup

This commit is contained in:
Oliver Booth 2023-08-08 12:40:51 +01:00
parent 9de1a84446
commit 56a8ba7368
Signed by: oliverbooth
GPG Key ID: 725DB725A0D9EE61

View File

@ -76,15 +76,30 @@ public sealed class BlogService
} }
/// <summary> /// <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> /// </summary>
/// <param name="postId">The WordPress ID of the post.</param> /// <param name="postId">The WordPress ID of the post.</param>
/// <param name="post"> /// <param name="post">
/// When this method returns, contains the <see cref="BlogPost" /> associated with the specified publication /// When this method returns, contains the <see cref="BlogPost" /> associated with ID, if the post is found;
/// date and slug, if the post is found; otherwise, <see langword="null" />. /// otherwise, <see langword="null" />.
/// </param> /// </param>
/// <returns><see langword="true" /> if the post is found; otherwise, <see langword="false" />.</returns> /// <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) public bool TryGetWordPressBlogPost(int postId, [NotNullWhen(true)] out BlogPost? post)
{ {
using BlogContext context = _dbContextFactory.CreateDbContext(); using BlogContext context = _dbContextFactory.CreateDbContext();