|
|
|
@ -44,11 +44,6 @@ namespace Volo.Blogging.Posts |
|
|
|
postDtos = await FilterPostsByTag(postDtos, tag); |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var postDto in postDtos) |
|
|
|
{ |
|
|
|
postDto.CommentCount = await _commentRepository.GetCommentCountOfPostAsync(postDto.Id); |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var postDto in postDtos) |
|
|
|
{ |
|
|
|
if (postDto.CreatorId.HasValue) |
|
|
|
@ -72,6 +67,24 @@ namespace Volo.Blogging.Posts |
|
|
|
return new ListResultDto<PostWithDetailsDto>(postDtos); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<ListResultDto<PostWithDetailsDto>> GetTimeOrderedListAsync(Guid blogId) |
|
|
|
{ |
|
|
|
var posts = await _postRepository.GetOrderedList(blogId); |
|
|
|
|
|
|
|
var postDtos = new List<PostWithDetailsDto>(ObjectMapper.Map<List<Post>, List<PostWithDetailsDto>>(posts)); |
|
|
|
|
|
|
|
foreach (var postDto in postDtos) |
|
|
|
{ |
|
|
|
var creatorUser = await UserLookupService.FindByIdAsync(postDto.CreatorId.Value); |
|
|
|
if (creatorUser != null) |
|
|
|
{ |
|
|
|
postDto.Writer = ObjectMapper.Map<BlogUser, BlogUserDto>(creatorUser); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return new ListResultDto<PostWithDetailsDto>(postDtos); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<PostWithDetailsDto> GetForReadingAsync(GetPostInput input) |
|
|
|
{ |
|
|
|
var post = await _postRepository.GetPostByUrl(input.BlogId, input.Url); |
|
|
|
@ -172,7 +185,7 @@ namespace Volo.Blogging.Posts |
|
|
|
{ |
|
|
|
var postList = await _postRepository.GetListAsync(); |
|
|
|
|
|
|
|
if (postList.Where(p => p.Url == url).WhereIf(existingPost != null, p => existingPost.Id != p.Id).Any()) |
|
|
|
if (postList.Where(p => p.Url == url).WhereIf(existingPost != null, p => existingPost.Id != p.Id).Any()) |
|
|
|
{ |
|
|
|
return url + "-" + Guid.NewGuid().ToString().Substring(0, 5); |
|
|
|
} |
|
|
|
@ -252,7 +265,7 @@ namespace Volo.Blogging.Posts |
|
|
|
private Task<List<PostWithDetailsDto>> FilterPostsByTag(IEnumerable<PostWithDetailsDto> allPostDtos, Tag tag) |
|
|
|
{ |
|
|
|
var filteredPostDtos = allPostDtos.Where(p => p.Tags?.Any(t => t.Id == tag.Id) ?? false).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
return Task.FromResult(filteredPostDtos); |
|
|
|
} |
|
|
|
} |
|
|
|
|