Browse Source

PostAppService: FilterPostsByTag refactor

pull/870/head
Yunus Emre Kalkan 8 years ago
parent
commit
972df578a3
  1. 14
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs

14
modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs

@ -253,18 +253,8 @@ namespace Volo.Blogging.Posts
private Task<List<PostWithDetailsDto>> FilterPostsByTag(List<PostWithDetailsDto> allPostDtos, Tag tag)
{
var filteredPostDtos = new List<PostWithDetailsDto>();
foreach (var postDto in allPostDtos)
{
if (postDto.Tags.All(p => p.Id != tag.Id))
{
continue;
}
filteredPostDtos.Add(postDto);
}
var filteredPostDtos = allPostDtos.Where(p => p.Tags?.Any(t => t.Id == tag.Id) ?? false).ToList();
return Task.FromResult(filteredPostDtos);
}
}

Loading…
Cancel
Save