Browse Source

The detail page should not give an error if a post is without an author

pull/16747/head
Salih 3 years ago
parent
commit
ddd04b8e5f
  1. 66
      modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml
  2. 10
      modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml.cs

66
modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml

@ -147,27 +147,31 @@
}
</div>
<div class="col ps-1">
<h5 class="mt-2 mb-1">
<a href="/Members/@Model.Post.Writer.UserName">
@if (Model.Post.Writer.Name != null && Model.Post.Writer.Surname != null)
{
<p class="fw-bold pt-2 fs-5">@Model.Post.Writer.Name @Model.Post.Writer.Surname</p>
}
else
@if (Model.Post.Writer != null)
{
<h5 class="mt-2 mb-1">
<a href="/Members/@Model.Post.Writer.UserName">
@if (Model.Post.Writer.Name != null && Model.Post.Writer.Surname != null)
{
<p class="fw-bold pt-2 fs-5">@Model.Post.Writer.Name @Model.Post.Writer.Surname</p>
}
else
{
<p class="fw-bold pt-2 fs-5">@Model.Post.Writer.UserName</p>
}
</a>
</h5>
<div class="position-relative">
@if (Model.Post.Writer.JobTitle != null)
{
<p class="fw-bold pt-2 fs-5">@Model.Post.Writer.UserName</p>
<p class="fw-lighter">@Model.Post.Writer.JobTitle</p>
}
</a>
</h5>
<div class="position-relative">
@if (Model.Post.Writer.JobTitle != null)
{
<p class="fw-lighter">@Model.Post.Writer.JobTitle</p>
}
</div>
@if (CurrentUser.UserName == Model.Post.Writer.UserName)
</div>
}
@if (CurrentUser.UserName == Model.Post.Writer?.UserName)
{
<a class="fw-lighter" href="/Members/@Model.Post.Writer.UserName#edit-profile">@L["EditProfile"] <i class="fas fa-edit"></i></a>
<a class="fw-lighter" href="/Members/@Model.Post.Writer?.UserName#edit-profile">@L["EditProfile"] <i class="fas fa-edit"></i></a>
}
</div>
@if (Model.LatestPosts.Count > 1)
@ -185,23 +189,23 @@
<div class="article-owner">
<div class="article-infos">
<div class="user-card pt-3">
<div class="row">
<div class="col-auto pe-1">
@if (post.Writer != null)
{
@if (post.Writer != null)
{
<div class="row">
<div class="col-auto pe-1">
<a href="/Members/@post.Writer.UserName" aria-label="Go to user profile">
<img gravatar-email="@post.Writer.Email" default-image="Identicon" class="last-post-image" alt="User Avatar"/>
</a>
}
</div>
<div class="col">
<h5 class="last-post-name">
<a href="/Members/@post.Writer.UserName">
@(post.Writer.UserName)
</a>
</h5>
</div>
<div class="col">
<h5 class="last-post-name">
<a href="/Members/@post.Writer?.UserName">
@(post.Writer?.UserName)
</a>
</h5>
</div>
</div>
</div>
}
</div>
</div>
<div class="col mt-2">

10
modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml.cs

@ -86,7 +86,15 @@ namespace Volo.Blogging.Pages.Blog.Posts
{
Blog = await _blogAppService.GetByShortNameAsync(BlogShortName);
Post = await _postAppService.GetForReadingAsync(new GetPostInput { BlogId = Blog.Id, Url = PostUrl });
PostsList = await _postAppService.GetListByUserIdAsync(Post.Writer.Id);
if (Post.Writer != null)
{
PostsList = await _postAppService.GetListByUserIdAsync(Post.Writer.Id);
}else
{
PostsList = new List<PostWithDetailsDto>();
}
LatestPosts = await _postAppService.GetLatestBlogPostsAsync(Blog.Id, 5);
CommentsWithReplies = await _commentAppService.GetHierarchicalListOfPostAsync(Post.Id);
CountComments();

Loading…
Cancel
Save