From c3919b412585d1515d097b362d73bd66e6653582 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 3 Sep 2021 13:42:24 +0800 Subject: [PATCH] Add async suffix to the application service asynchronous method --- .../Volo/Abp/Account/AccountAppService.cs | 4 +-- .../Volo/Blogging/Posts/PostAppService.cs | 34 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs b/modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs index 05ff98b35b..5c6612d1cc 100644 --- a/modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs +++ b/modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs @@ -55,7 +55,7 @@ namespace Volo.Abp.Account public virtual async Task SendPasswordResetCodeAsync(SendPasswordResetCodeDto input) { - var user = await GetUserByEmail(input.Email); + var user = await GetUserByEmailAsync(input.Email); var resetToken = await UserManager.GeneratePasswordResetTokenAsync(user); await AccountEmailer.SendPasswordResetLinkAsync(user, resetToken, input.AppName, input.ReturnUrl, input.ReturnUrlHash); } @@ -74,7 +74,7 @@ namespace Volo.Abp.Account }); } - protected virtual async Task GetUserByEmail(string email) + protected virtual async Task GetUserByEmailAsync(string email) { var user = await UserManager.FindByEmailAsync(email); if (user == null) 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 65b8575091..a886649104 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 @@ -41,24 +41,24 @@ namespace Volo.Blogging.Posts _postsCache = postsCache; _localEventBus = localEventBus; } - + public async Task> GetListByBlogIdAndTagNameAsync(Guid id, string tagName) { var posts = await _postRepository.GetPostsByBlogId(id); var tag = tagName.IsNullOrWhiteSpace() ? null : await _tagRepository.FindByNameAsync(id, tagName); var userDictionary = new Dictionary(); var postDtos = new List(ObjectMapper.Map, List>(posts)); - + foreach (var postDto in postDtos) { - postDto.Tags = await GetTagsOfPost(postDto.Id); + postDto.Tags = await GetTagsOfPostAsync(postDto.Id); } - + if (tag != null) { - postDtos = await FilterPostsByTag(postDtos, tag); + postDtos = await FilterPostsByTagAsync(postDtos, tag); } - + foreach (var postDto in postDtos) { if (postDto.CreatorId.HasValue) @@ -71,17 +71,17 @@ namespace Volo.Blogging.Posts userDictionary[creatorUser.Id] = ObjectMapper.Map(creatorUser); } } - + if (userDictionary.ContainsKey(postDto.CreatorId.Value)) { postDto.Writer = userDictionary[(Guid)postDto.CreatorId]; } } } - + return new ListResultDto(postDtos); } - + public async Task> GetTimeOrderedListAsync(Guid blogId) { var postCacheItems = await _postsCache.GetOrAddAsync( @@ -94,7 +94,7 @@ namespace Volo.Blogging.Posts ); var postsWithDetails = ObjectMapper.Map, List>(postCacheItems); - + foreach (var post in postsWithDetails) { if (post.CreatorId.HasValue) @@ -106,7 +106,7 @@ namespace Volo.Blogging.Posts } } } - + return new ListResultDto(postsWithDetails); } @@ -118,7 +118,7 @@ namespace Volo.Blogging.Posts var postDto = ObjectMapper.Map(post); - postDto.Tags = await GetTagsOfPost(postDto.Id); + postDto.Tags = await GetTagsOfPostAsync(postDto.Id); if (postDto.CreatorId.HasValue) { @@ -136,7 +136,7 @@ namespace Volo.Blogging.Posts var postDto = ObjectMapper.Map(post); - postDto.Tags = await GetTagsOfPost(postDto.Id); + postDto.Tags = await GetTagsOfPostAsync(postDto.Id); if (postDto.CreatorId.HasValue) { @@ -155,7 +155,7 @@ namespace Volo.Blogging.Posts await AuthorizationService.CheckAsync(post, CommonOperations.Delete); - var tags = await GetTagsOfPost(id); + var tags = await GetTagsOfPostAsync(id); await _tagRepository.DecreaseUsageCountOfTagsAsync(tags.Select(t => t.Id).ToList()); await _commentRepository.DeleteOfPost(id); @@ -220,7 +220,7 @@ namespace Volo.Blogging.Posts return ObjectMapper.Map, List>(posts); } - + private async Task RenameUrlIfItAlreadyExistAsync(Guid blogId, string url, Post existingPost = null) { if (await _postRepository.IsPostUrlInUseAsync(blogId, url, existingPost?.Id)) @@ -282,7 +282,7 @@ namespace Volo.Blogging.Posts } } - private async Task> GetTagsOfPost(Guid id) + private async Task> GetTagsOfPostAsync(Guid id) { var tagIds = (await _postRepository.GetAsync(id)).Tags; @@ -300,7 +300,7 @@ namespace Volo.Blogging.Posts return new List(tags.Split(",").Select(t => t.Trim())); } - private Task> FilterPostsByTag(IEnumerable allPostDtos, Tag tag) + private Task> FilterPostsByTagAsync(IEnumerable allPostDtos, Tag tag) { var filteredPostDtos = allPostDtos.Where(p => p.Tags?.Any(t => t.Id == tag.Id) ?? false).ToList();