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 a8232933a4..be51085f86 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 @@ -118,7 +118,7 @@ namespace Volo.Blogging.Posts await AuthorizationService.CheckAsync(post, CommonOperations.Delete); var tags = await GetTagsOfPost(id); - _tagRepository.DecreaseUsageCountOfTags(tags.Select(t => t.Id).ToList()); + await _tagRepository.DecreaseUsageCountOfTagsAsync(tags.Select(t => t.Id).ToList()); await _commentRepository.DeleteOfPost(id); await _postRepository.DeleteAsync(id); diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Tagging/ITagRepository.cs b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Tagging/ITagRepository.cs index 33858b9baf..8c076c49d7 100644 --- a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Tagging/ITagRepository.cs +++ b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Tagging/ITagRepository.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; @@ -15,6 +16,6 @@ namespace Volo.Blogging.Tagging Task> GetListAsync(IEnumerable ids); - void DecreaseUsageCountOfTags(List id); + Task DecreaseUsageCountOfTagsAsync(List id, CancellationToken cancellationToken = default); } } diff --git a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Tagging/EfCoreTagRepository.cs b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Tagging/EfCoreTagRepository.cs index cd77b3cfab..3e897fa7e3 100644 --- a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Tagging/EfCoreTagRepository.cs +++ b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Tagging/EfCoreTagRepository.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; @@ -36,9 +37,11 @@ namespace Volo.Blogging.Tagging return await DbSet.Where(t => ids.Contains(t.Id)).ToListAsync(); } - public void DecreaseUsageCountOfTags(List ids) + public async Task DecreaseUsageCountOfTagsAsync(List ids, CancellationToken cancellationToken = default) { - var tags = DbSet.Where(t => ids.Any(id => id == t.Id)); + var tags = await DbSet + .Where(t => ids.Any(id => id == t.Id)) + .ToListAsync(GetCancellationToken(cancellationToken)); foreach (var tag in tags) { diff --git a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Tagging/MongoTagRepository.cs b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Tagging/MongoTagRepository.cs index e2fcdca96c..2c0b3b97bf 100644 --- a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Tagging/MongoTagRepository.cs +++ b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Tagging/MongoTagRepository.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using MongoDB.Driver; using MongoDB.Driver.Linq; @@ -19,7 +20,7 @@ namespace Volo.Blogging.Tagging public async Task> GetListAsync(Guid blogId) { - return await GetMongoQueryable().Where(t=>t.BlogId == blogId).ToListAsync(); + return await GetMongoQueryable().Where(t => t.BlogId == blogId).ToListAsync(); } public async Task GetByNameAsync(Guid blogId, string name) @@ -37,14 +38,16 @@ namespace Volo.Blogging.Tagging return await GetMongoQueryable().Where(t => ids.Contains(t.Id)).ToListAsync(); } - public void DecreaseUsageCountOfTags(List ids) + public async Task DecreaseUsageCountOfTagsAsync(List ids, CancellationToken cancellationToken = default) { - var tags = GetMongoQueryable().Where(t => ids.Contains(t.Id)); + var tags = await GetMongoQueryable() + .Where(t => ids.Contains(t.Id)) + .ToListAsync(GetCancellationToken(cancellationToken)); foreach (var tag in tags) { tag.DecreaseUsageCount(); - Update(tag); + await UpdateAsync(tag, cancellationToken: GetCancellationToken(cancellationToken)); } } } diff --git a/modules/blogging/test/Volo.Blogging.TestBase/Volo/Blogging/Tagging/TagRepository_Tests.cs b/modules/blogging/test/Volo.Blogging.TestBase/Volo/Blogging/Tagging/TagRepository_Tests.cs index a81c7dde1e..0706ad3f4a 100644 --- a/modules/blogging/test/Volo.Blogging.TestBase/Volo/Blogging/Tagging/TagRepository_Tests.cs +++ b/modules/blogging/test/Volo.Blogging.TestBase/Volo/Blogging/Tagging/TagRepository_Tests.cs @@ -60,7 +60,7 @@ namespace Volo.Blogging.Tagging var tag = await TagRepository.FindByNameAsync(BloggingTestData.Blog1Id, BloggingTestData.Tag1Name); var usageCount = tag.UsageCount; - TagRepository.DecreaseUsageCountOfTags(new List() + await TagRepository.DecreaseUsageCountOfTagsAsync(new List() { tag.Id }); diff --git a/modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocsTestBaseModule.cs b/modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocsTestBaseModule.cs index a4661075d0..ffc11fd134 100644 --- a/modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocsTestBaseModule.cs +++ b/modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocsTestBaseModule.cs @@ -3,6 +3,7 @@ using Volo.Abp; using Volo.Abp.Authorization; using Volo.Abp.Autofac; using Volo.Abp.Modularity; +using Volo.Abp.Threading; namespace Volo.Docs { @@ -28,9 +29,9 @@ namespace Volo.Docs { using (var scope = context.ServiceProvider.CreateScope()) { - scope.ServiceProvider + AsyncHelper.RunSync(() => scope.ServiceProvider .GetRequiredService() - .Build(); + .BuildAsync()); } } } diff --git a/modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocsTestDataBuilder.cs b/modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocsTestDataBuilder.cs index 15fa70eee7..121d18b44a 100644 --- a/modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocsTestDataBuilder.cs +++ b/modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocsTestDataBuilder.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Data; +using System.Threading.Tasks; +using Volo.Abp.Data; using Volo.Abp.DependencyInjection; using Volo.Docs.GitHub.Documents; using Volo.Docs.Projects; @@ -18,7 +19,7 @@ namespace Volo.Docs _projectRepository = projectRepository; } - public void Build() + public async Task BuildAsync() { var project = new Project( _testData.PorjectId, @@ -36,7 +37,7 @@ namespace Volo.Docs .SetProperty("GitHubAccessToken", "123456") .SetProperty("GitHubUserAgent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"); - _projectRepository.Insert(project); + await _projectRepository.InsertAsync(project); } } } \ No newline at end of file diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/ITenantRepository.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/ITenantRepository.cs index d8725bf6cf..1feca866a2 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/ITenantRepository.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/ITenantRepository.cs @@ -18,6 +18,11 @@ namespace Volo.Abp.TenantManagement bool includeDetails = true ); + Tenant FindById( + Guid id, + bool includeDetails = true + ); + Task> GetListAsync( string sorting = null, int maxResultCount = int.MaxValue, diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/TenantStore.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/TenantStore.cs index cc0788d634..afa9af0cf2 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/TenantStore.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/TenantStore.cs @@ -70,7 +70,7 @@ namespace Volo.Abp.TenantManagement { using (_currentTenant.Change(null)) //TODO: No need this if we can implement to define host side (or tenant-independent) entities! { - var tenant = _tenantRepository.Find(id); + var tenant = _tenantRepository.FindById(id); if (tenant == null) { return null; diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.EntityFrameworkCore/Volo/Abp/TenantManagement/EntityFrameworkCore/EfCoreTenantRepository.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.EntityFrameworkCore/Volo/Abp/TenantManagement/EntityFrameworkCore/EfCoreTenantRepository.cs index c1188d2859..e211f81abf 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.EntityFrameworkCore/Volo/Abp/TenantManagement/EntityFrameworkCore/EfCoreTenantRepository.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.EntityFrameworkCore/Volo/Abp/TenantManagement/EntityFrameworkCore/EfCoreTenantRepository.cs @@ -35,6 +35,13 @@ namespace Volo.Abp.TenantManagement.EntityFrameworkCore .FirstOrDefault(t => t.Name == name); } + public Tenant FindById(Guid id, bool includeDetails = true) + { + return DbSet + .IncludeDetails(includeDetails) + .FirstOrDefault(t => t.Id == id); + } + public virtual async Task> GetListAsync( string sorting = null, int maxResultCount = int.MaxValue, diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.MongoDB/Volo/Abp/TenantManagement/MongoDb/MongoTenantRepository.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.MongoDB/Volo/Abp/TenantManagement/MongoDb/MongoTenantRepository.cs index 389f55d5db..1d57652833 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.MongoDB/Volo/Abp/TenantManagement/MongoDb/MongoTenantRepository.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.MongoDB/Volo/Abp/TenantManagement/MongoDb/MongoTenantRepository.cs @@ -34,6 +34,12 @@ namespace Volo.Abp.TenantManagement.MongoDB .FirstOrDefault(t => t.Name == name); } + public Tenant FindById(Guid id, bool includeDetails = true) + { + return GetMongoQueryable() + .FirstOrDefault(t => t.Id == id); + } + public virtual async Task> GetListAsync( string sorting = null, int maxResultCount = int.MaxValue,