Browse Source

refactoring

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

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

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

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

@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Abp.Domain.Entities;
using Volo.Blogging.Blogs;
using Volo.Blogging.Blogs.Dtos;
using Volo.Blogging.Pages.Blogs.Shared.Helpers;
@ -43,11 +45,13 @@ namespace Volo.Blogging.Pages.Blog.Posts
return NotFound();
}
Blog = await _blogAppService.GetByShortNameAsync(BlogShortName);
if (Blog == null)
try
{
return RedirectToPage("/Blogs/Index");
Blog = await _blogAppService.GetByShortNameAsync(BlogShortName);
}
catch (EntityNotFoundException)
{
return RedirectToPage("/Blogs/Index");
}
Posts = (await _postAppService.GetListByBlogIdAndTagNameAsync(Blog.Id, TagName)).Items;

Loading…
Cancel
Save