fix: add missing method from BlogService
This commit is contained in:
parent
87c54fa5a4
commit
221a6f0007
@ -61,7 +61,25 @@ public sealed class BlogService
|
|||||||
int moreIndex = span.IndexOf("<!--more-->", StringComparison.Ordinal);
|
int moreIndex = span.IndexOf("<!--more-->", StringComparison.Ordinal);
|
||||||
trimmed = moreIndex != -1 || span.Length > 256;
|
trimmed = moreIndex != -1 || span.Length > 256;
|
||||||
string result = moreIndex != -1 ? span[..moreIndex].Trim().ToString() : post.Body.Truncate(256);
|
string result = moreIndex != -1 ? span[..moreIndex].Trim().ToString() : post.Body.Truncate(256);
|
||||||
return RenderContent(result);
|
return RenderContent(result).Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to find the author by ID.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The ID of the author.</param>
|
||||||
|
/// <param name="author">
|
||||||
|
/// When this method returns, contains the <see cref="Author" /> associated with the specified ID, if the author
|
||||||
|
/// is found; otherwise, <see langword="null" />.
|
||||||
|
/// </param>
|
||||||
|
/// <returns><see langword="true" /> if the author is found; otherwise, <see langword="false" />.</returns>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="post" /> is <see langword="null" />.</exception>
|
||||||
|
public bool TryGetAuthor(int id, [NotNullWhen(true)] out Author? author)
|
||||||
|
{
|
||||||
|
using BlogContext context = _dbContextFactory.CreateDbContext();
|
||||||
|
author = context.Authors.FirstOrDefault(a => a.Id == id);
|
||||||
|
|
||||||
|
return author is not null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -71,6 +89,7 @@ public sealed class BlogService
|
|||||||
/// <param name="author">
|
/// <param name="author">
|
||||||
/// When this method returns, contains the <see cref="Author" /> associated with the specified blog post, if the
|
/// When this method returns, contains the <see cref="Author" /> associated with the specified blog post, if the
|
||||||
/// author is found; otherwise, <see langword="null" />.
|
/// author is found; otherwise, <see langword="null" />.
|
||||||
|
/// </param>
|
||||||
/// <returns><see langword="true" /> if the author is found; otherwise, <see langword="false" />.</returns>
|
/// <returns><see langword="true" /> if the author is found; otherwise, <see langword="false" />.</returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="post" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="post" /> is <see langword="null" />.</exception>
|
||||||
public bool TryGetAuthor(BlogPost post, [NotNullWhen(true)] out Author? author)
|
public bool TryGetAuthor(BlogPost post, [NotNullWhen(true)] out Author? author)
|
||||||
|
Loading…
Reference in New Issue
Block a user