diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml index 1ebf445f05..cc37c15c89 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml @@ -147,27 +147,32 @@ }
-
- - @if (Model.Post.Writer.Name != null && Model.Post.Writer.Surname != null) - { -

@Model.Post.Writer.Name @Model.Post.Writer.Surname

- } - else + @if (Model.Post.Writer != null) + { +
+ + + @if (Model.Post.Writer.Name != null && Model.Post.Writer.Surname != null) + { +

@Model.Post.Writer.Name @Model.Post.Writer.Surname

+ } + else + { +

@Model.Post.Writer.UserName

+ } +
+
+
+ @if (Model.Post.Writer.JobTitle != null) { -

@Model.Post.Writer.UserName

+

@Model.Post.Writer.JobTitle

} - -
-
- @if (Model.Post.Writer.JobTitle != null) - { -

@Model.Post.Writer.JobTitle

- } -
- @if (CurrentUser.UserName == Model.Post.Writer.UserName) +
+ } + + @if (CurrentUser.Id.HasValue && CurrentUser.Id.Value == Model.Post.Writer?.Id) { - @L["EditProfile"] + @L["EditProfile"] } @if (Model.LatestPosts.Count > 1) @@ -185,23 +190,24 @@
-
-
- @if (post.Writer != null) - { + @if (post.Writer != null) + { + -
+ }
diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml.cs index 54d1a4e71d..114bdbb641 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml.cs @@ -86,7 +86,11 @@ 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); + + PostsList = Post.Writer != null + ? await _postAppService.GetListByUserIdAsync(Post.Writer.Id) + : new List(); + LatestPosts = await _postAppService.GetLatestBlogPostsAsync(Blog.Id, 5); CommentsWithReplies = await _commentAppService.GetHierarchicalListOfPostAsync(Post.Id); CountComments();