Browse Source

Add async suffix to the application service asynchronous method

pull/9965/head
liangshiwei 5 years ago
parent
commit
c3919b4125
  1. 4
      modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs
  2. 34
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs

4
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<IdentityUser> GetUserByEmail(string email)
protected virtual async Task<IdentityUser> GetUserByEmailAsync(string email)
{
var user = await UserManager.FindByEmailAsync(email);
if (user == null)

34
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<ListResultDto<PostWithDetailsDto>> 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<Guid, BlogUserDto>();
var postDtos = new List<PostWithDetailsDto>(ObjectMapper.Map<List<Post>, List<PostWithDetailsDto>>(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<BlogUser, BlogUserDto>(creatorUser);
}
}
if (userDictionary.ContainsKey(postDto.CreatorId.Value))
{
postDto.Writer = userDictionary[(Guid)postDto.CreatorId];
}
}
}
return new ListResultDto<PostWithDetailsDto>(postDtos);
}
public async Task<ListResultDto<PostWithDetailsDto>> GetTimeOrderedListAsync(Guid blogId)
{
var postCacheItems = await _postsCache.GetOrAddAsync(
@ -94,7 +94,7 @@ namespace Volo.Blogging.Posts
);
var postsWithDetails = ObjectMapper.Map<List<PostCacheItem>, List<PostWithDetailsDto>>(postCacheItems);
foreach (var post in postsWithDetails)
{
if (post.CreatorId.HasValue)
@ -106,7 +106,7 @@ namespace Volo.Blogging.Posts
}
}
}
return new ListResultDto<PostWithDetailsDto>(postsWithDetails);
}
@ -118,7 +118,7 @@ namespace Volo.Blogging.Posts
var postDto = ObjectMapper.Map<Post, PostWithDetailsDto>(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, PostWithDetailsDto>(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<Post>, List<PostCacheItem>>(posts);
}
private async Task<string> 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<List<TagDto>> GetTagsOfPost(Guid id)
private async Task<List<TagDto>> GetTagsOfPostAsync(Guid id)
{
var tagIds = (await _postRepository.GetAsync(id)).Tags;
@ -300,7 +300,7 @@ namespace Volo.Blogging.Posts
return new List<string>(tags.Split(",").Select(t => t.Trim()));
}
private Task<List<PostWithDetailsDto>> FilterPostsByTag(IEnumerable<PostWithDetailsDto> allPostDtos, Tag tag)
private Task<List<PostWithDetailsDto>> FilterPostsByTagAsync(IEnumerable<PostWithDetailsDto> allPostDtos, Tag tag)
{
var filteredPostDtos = allPostDtos.Where(p => p.Tags?.Any(t => t.Id == tag.Id) ?? false).ToList();

Loading…
Cancel
Save