From 972df578a353b6338a0fe4894a1d67b5c0e06bb8 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Mon, 11 Mar 2019 08:29:03 +0300 Subject: [PATCH] PostAppService: FilterPostsByTag refactor --- .../Volo/Blogging/Posts/PostAppService.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs index 5ba5a11e9f..34488f77a1 100644 --- a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs @@ -253,18 +253,8 @@ namespace Volo.Blogging.Posts private Task> FilterPostsByTag(List allPostDtos, Tag tag) { - var filteredPostDtos = new List(); - - 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); } }