From ddd04b8e5f4fc395e345b0ed5ab0f78eeb4f9f78 Mon Sep 17 00:00:00 2001 From: Salih Date: Mon, 5 Jun 2023 08:31:17 +0300 Subject: [PATCH 1/2] The detail page should not give an error if a post is without an author --- .../Pages/Blogs/Posts/Detail.cshtml | 66 ++++++++++--------- .../Pages/Blogs/Posts/Detail.cshtml.cs | 10 ++- 2 files changed, 44 insertions(+), 32 deletions(-) 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..d2746284ba 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,31 @@ }
-
- - @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.UserName == Model.Post.Writer?.UserName) { - @L["EditProfile"] + @L["EditProfile"] } @if (Model.LatestPosts.Count > 1) @@ -185,23 +189,23 @@
+ 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 b200266f0c..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 @@ -87,13 +87,9 @@ namespace Volo.Blogging.Pages.Blog.Posts Blog = await _blogAppService.GetByShortNameAsync(BlogShortName); Post = await _postAppService.GetForReadingAsync(new GetPostInput { BlogId = Blog.Id, Url = PostUrl }); - if (Post.Writer != null) - { - PostsList = await _postAppService.GetListByUserIdAsync(Post.Writer.Id); - }else - { - PostsList = new List(); - } + 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);