Browse Source

Blog: added redirect if blog name is null

pull/16723/head
Onur Pıçakcı 3 years ago
parent
commit
9da4dc960a
  1. 5
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs
  2. 6
      modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml.cs

5
modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs

@ -33,11 +33,6 @@ namespace Volo.Blogging.Blogs
var blog = await BlogRepository.FindByShortNameAsync(shortName);
if (blog == null)
{
throw new EntityNotFoundException(typeof(Blog), shortName);
}
return ObjectMapper.Map<Blog, BlogDto>(blog);
}

6
modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml.cs

@ -44,6 +44,12 @@ namespace Volo.Blogging.Pages.Blog.Posts
}
Blog = await _blogAppService.GetByShortNameAsync(BlogShortName);
if (Blog == null)
{
return RedirectToPage("/Blogs/Index");
}
Posts = (await _postAppService.GetListByBlogIdAndTagNameAsync(Blog.Id, TagName)).Items;
PopularTags = (await _tagAppService.GetPopularTagsAsync(Blog.Id, new GetPopularTagsInput {ResultCount = 10, MinimumPostCount = 2}));

Loading…
Cancel
Save