Browse Source

Add `virtual` keyword to `Repositories&AppServices&Controllers`.

pull/17117/head
maliming 3 years ago
parent
commit
2c7879d2c7
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationLocalizationAppService.cs
  2. 4
      framework/src/Volo.Abp.Dapper/Volo/Abp/Domain/Repositories/Dapper/DapperRepository.cs
  3. 2
      framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs
  4. 4
      framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs
  5. 12
      modules/blogging/src/Volo.Blogging.Admin.Application/Volo/Blogging/Admin/Blogs/BlogManagementAppService.cs
  6. 12
      modules/blogging/src/Volo.Blogging.Admin.HttpApi/Volo/Blogging/Admin/BlogManagementController.cs
  7. 6
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs
  8. 8
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Comments/CommentAppService.cs
  9. 4
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs
  10. 18
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs
  11. 2
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Tagging/TagAppService.cs
  12. 2
      modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Blogs/EfCoreBlogRepository.cs
  13. 8
      modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Comments/EfCoreCommentRepository.cs
  14. 12
      modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs
  15. 10
      modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Tagging/EfCoreTagRepository.cs
  16. 2
      modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Users/EfCoreBlogUserRepository.cs
  17. 2
      modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogFilesController.cs
  18. 6
      modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs
  19. 2
      modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Blogs/MongoBlogRepository.cs
  20. 8
      modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Comments/MongoCommentRepository.cs
  21. 12
      modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs
  22. 10
      modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Tagging/MongoTagRepository.cs
  23. 2
      modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Users/MongoBlogUserRepository.cs
  24. 4
      modules/blogging/src/Volo.Blogging.Web/Areas/Blog/Controllers/CommentsController.cs
  25. 2
      modules/blogging/src/Volo.Blogging.Web/Areas/Blog/Controllers/PostsController.cs
  26. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs
  27. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/GlobalResources/GlobalResourceAdminAppService.cs
  28. 10
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/TagAdminAppService.cs
  29. 4
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogFeatureRepository.cs
  30. 10
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs
  31. 10
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs
  32. 4
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Ratings/EfCoreRatingRepository.cs
  33. 6
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs
  34. 2
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreEntityTagRepository.cs
  35. 4
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs
  36. 6
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs
  37. 2
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoEntityTagRepository.cs
  38. 6
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs
  39. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs
  40. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/GlobalResources/GlobalResourcePublicAppService.cs
  41. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Menus/MenuItemPublicAppService.cs
  42. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Controllers/CmsKitPublicCommentsController.cs
  43. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Controllers/CmsKitPublicGlobalResourcesController.cs
  44. 14
      modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs
  45. 16
      modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Projects/ProjectAdminAppService.cs
  46. 6
      modules/docs/src/Volo.Docs.Admin.HttpApi/Volo/Docs/Admin/DocumentsAdminController.cs
  47. 10
      modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs
  48. 10
      modules/docs/src/Volo.Docs.Application/Volo/Docs/Projects/ProjectAppService.cs
  49. 18
      modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs
  50. 8
      modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Projects/EfCoreProjectRepository.cs
  51. 18
      modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs
  52. 8
      modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Projects/MongoProjectRepository.cs
  53. 2
      modules/docs/src/Volo.Docs.Web/Areas/Documents/DocumentResourceController.cs
  54. 4
      modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/EfCoreFeatureValueRepository.cs
  55. 2
      modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureValueRepository.cs
  56. 4
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs
  57. 6
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserDelegationRepository.cs
  58. 6
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserDelegationRepository.cs
  59. 6
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs
  60. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiScopes/ApiScopeRepository.cs
  61. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Clients/ClientRepository.cs
  62. 4
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Grants/PersistentGrantRepository.cs
  63. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceRepository.cs
  64. 6
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiResourceRepository.cs
  65. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiScopeRepository.cs
  66. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoClientRepository.cs
  67. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoIdentityResourceRepository.cs
  68. 4
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoPersistentGrantRepository.cs
  69. 4
      modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Applications/EfCoreOpenIddictApplicationRepository.cs
  70. 4
      modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Scopes/EfCoreOpenIddictScopeRepository.cs
  71. 14
      modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Applications/MongoOpenIddictApplicationRepository.cs
  72. 4
      modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Scopes/MongoOpenIddictScopeRepository.cs
  73. 2
      modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo/Abp/PermissionManagement/EntityFrameworkCore/EfCorePermissionDefinitionRecordRepository.cs
  74. 2
      modules/permission-management/src/Volo.Abp.PermissionManagement.MongoDB/Volo/Abp/PermissionManagement/MongoDb/MongoPermissionDefinitionRecordRepository.cs

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationLocalizationAppService.cs

@ -24,7 +24,7 @@ public class AbpApplicationLocalizationAppService :
LocalizationOptions = localizationOptions.Value; LocalizationOptions = localizationOptions.Value;
} }
public async Task<ApplicationLocalizationDto> GetAsync(ApplicationLocalizationRequestDto input) public virtual async Task<ApplicationLocalizationDto> GetAsync(ApplicationLocalizationRequestDto input)
{ {
if (!CultureHelper.IsValidCultureCode(input.CultureName)) if (!CultureHelper.IsValidCultureCode(input.CultureName))
{ {

4
framework/src/Volo.Abp.Dapper/Volo/Abp/Domain/Repositories/Dapper/DapperRepository.cs

@ -36,12 +36,12 @@ public class DapperRepository<TDbContext> : IDapperRepository, IUnitOfWorkEnable
[Obsolete("Use GetDbConnectionAsync method.")] [Obsolete("Use GetDbConnectionAsync method.")]
public IDbConnection DbConnection => _dbContextProvider.GetDbContext().Database.GetDbConnection(); public IDbConnection DbConnection => _dbContextProvider.GetDbContext().Database.GetDbConnection();
public async Task<IDbConnection> GetDbConnectionAsync() => (await _dbContextProvider.GetDbContextAsync()).Database.GetDbConnection(); public virtual async Task<IDbConnection> GetDbConnectionAsync() => (await _dbContextProvider.GetDbContextAsync()).Database.GetDbConnection();
[Obsolete("Use GetDbTransactionAsync method.")] [Obsolete("Use GetDbTransactionAsync method.")]
public IDbTransaction DbTransaction => _dbContextProvider.GetDbContext().Database.CurrentTransaction?.GetDbTransaction(); public IDbTransaction DbTransaction => _dbContextProvider.GetDbContext().Database.CurrentTransaction?.GetDbTransaction();
public async Task<IDbTransaction> GetDbTransactionAsync() => (await _dbContextProvider.GetDbContextAsync()).Database.CurrentTransaction?.GetDbTransaction(); public virtual async Task<IDbTransaction> GetDbTransactionAsync() => (await _dbContextProvider.GetDbContextAsync()).Database.CurrentTransaction?.GetDbTransaction();
protected virtual CancellationToken GetCancellationToken(CancellationToken preferredValue = default) protected virtual CancellationToken GetCancellationToken(CancellationToken preferredValue = default)
{ {

2
framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs

@ -25,7 +25,7 @@ public class MemoryDbRepository<TMemoryDbContext, TEntity> : RepositoryBase<TEnt
[Obsolete("Use GetCollectionAsync method.")] [Obsolete("Use GetCollectionAsync method.")]
public virtual IMemoryDatabaseCollection<TEntity> Collection => Database.Collection<TEntity>(); public virtual IMemoryDatabaseCollection<TEntity> Collection => Database.Collection<TEntity>();
public async Task<IMemoryDatabaseCollection<TEntity>> GetCollectionAsync() public virtual async Task<IMemoryDatabaseCollection<TEntity>> GetCollectionAsync()
{ {
return (await GetDatabaseAsync()).Collection<TEntity>(); return (await GetDatabaseAsync()).Collection<TEntity>();
} }

4
framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs

@ -30,7 +30,7 @@ public class MongoDbRepository<TMongoDbContext, TEntity>
[Obsolete("Use GetCollectionAsync method.")] [Obsolete("Use GetCollectionAsync method.")]
public virtual IMongoCollection<TEntity> Collection => DbContext.Collection<TEntity>(); public virtual IMongoCollection<TEntity> Collection => DbContext.Collection<TEntity>();
public async Task<IMongoCollection<TEntity>> GetCollectionAsync(CancellationToken cancellationToken = default) public virtual async Task<IMongoCollection<TEntity>> GetCollectionAsync(CancellationToken cancellationToken = default)
{ {
return (await GetDbContextAsync(GetCancellationToken(cancellationToken))).Collection<TEntity>(); return (await GetDbContextAsync(GetCancellationToken(cancellationToken))).Collection<TEntity>();
} }
@ -38,7 +38,7 @@ public class MongoDbRepository<TMongoDbContext, TEntity>
[Obsolete("Use GetDatabaseAsync method.")] [Obsolete("Use GetDatabaseAsync method.")]
public virtual IMongoDatabase Database => DbContext.Database; public virtual IMongoDatabase Database => DbContext.Database;
public async Task<IMongoDatabase> GetDatabaseAsync(CancellationToken cancellationToken = default) public virtual async Task<IMongoDatabase> GetDatabaseAsync(CancellationToken cancellationToken = default)
{ {
return (await GetDbContextAsync(GetCancellationToken(cancellationToken))).Database; return (await GetDbContextAsync(GetCancellationToken(cancellationToken))).Database;
} }

12
modules/blogging/src/Volo.Blogging.Admin.Application/Volo/Blogging/Admin/Blogs/BlogManagementAppService.cs

@ -22,7 +22,7 @@ namespace Volo.Blogging.Admin.Blogs
_postsCache = postsCache; _postsCache = postsCache;
} }
public async Task<ListResultDto<BlogDto>> GetListAsync() public virtual async Task<ListResultDto<BlogDto>> GetListAsync()
{ {
var blogs = await _blogRepository.GetListAsync(); var blogs = await _blogRepository.GetListAsync();
@ -31,7 +31,7 @@ namespace Volo.Blogging.Admin.Blogs
); );
} }
public async Task<BlogDto> GetAsync(Guid id) public virtual async Task<BlogDto> GetAsync(Guid id)
{ {
var blog = await _blogRepository.GetAsync(id); var blog = await _blogRepository.GetAsync(id);
@ -39,7 +39,7 @@ namespace Volo.Blogging.Admin.Blogs
} }
[Authorize(BloggingPermissions.Blogs.Create)] [Authorize(BloggingPermissions.Blogs.Create)]
public async Task<BlogDto> CreateAsync(CreateBlogDto input) public virtual async Task<BlogDto> CreateAsync(CreateBlogDto input)
{ {
var newBlog = new Blog(GuidGenerator.Create(), input.Name, input.ShortName) var newBlog = new Blog(GuidGenerator.Create(), input.Name, input.ShortName)
{ {
@ -52,7 +52,7 @@ namespace Volo.Blogging.Admin.Blogs
} }
[Authorize(BloggingPermissions.Blogs.Update)] [Authorize(BloggingPermissions.Blogs.Update)]
public async Task<BlogDto> UpdateAsync(Guid id, UpdateBlogDto input) public virtual async Task<BlogDto> UpdateAsync(Guid id, UpdateBlogDto input)
{ {
var blog = await _blogRepository.GetAsync(id); var blog = await _blogRepository.GetAsync(id);
@ -65,13 +65,13 @@ namespace Volo.Blogging.Admin.Blogs
} }
[Authorize(BloggingPermissions.Blogs.Delete)] [Authorize(BloggingPermissions.Blogs.Delete)]
public async Task DeleteAsync(Guid id) public virtual async Task DeleteAsync(Guid id)
{ {
await _blogRepository.DeleteAsync(id); await _blogRepository.DeleteAsync(id);
} }
[Authorize(BloggingPermissions.Blogs.ClearCache)] [Authorize(BloggingPermissions.Blogs.ClearCache)]
public async Task ClearCacheAsync(Guid id) public virtual async Task ClearCacheAsync(Guid id)
{ {
await _postsCache.RemoveAsync(id.ToString()); await _postsCache.RemoveAsync(id.ToString());
} }

12
modules/blogging/src/Volo.Blogging.Admin.HttpApi/Volo/Blogging/Admin/BlogManagementController.cs

@ -23,41 +23,41 @@ namespace Volo.Blogging.Admin
} }
[HttpGet] [HttpGet]
public async Task<ListResultDto<BlogDto>> GetListAsync() public virtual async Task<ListResultDto<BlogDto>> GetListAsync()
{ {
return await _blogManagementAppService.GetListAsync(); return await _blogManagementAppService.GetListAsync();
} }
[HttpGet] [HttpGet]
[Route("{id}")] [Route("{id}")]
public async Task<BlogDto> GetAsync(Guid id) public virtual async Task<BlogDto> GetAsync(Guid id)
{ {
return await _blogManagementAppService.GetAsync(id); return await _blogManagementAppService.GetAsync(id);
} }
[HttpPost] [HttpPost]
public async Task<BlogDto> CreateAsync(CreateBlogDto input) public virtual async Task<BlogDto> CreateAsync(CreateBlogDto input)
{ {
return await _blogManagementAppService.CreateAsync(input); return await _blogManagementAppService.CreateAsync(input);
} }
[HttpPut] [HttpPut]
[Route("{id}")] [Route("{id}")]
public async Task<BlogDto> UpdateAsync(Guid id, UpdateBlogDto input) public virtual async Task<BlogDto> UpdateAsync(Guid id, UpdateBlogDto input)
{ {
return await _blogManagementAppService.UpdateAsync(id, input); return await _blogManagementAppService.UpdateAsync(id, input);
} }
[HttpDelete] [HttpDelete]
[Route("{id}")] [Route("{id}")]
public async Task DeleteAsync(Guid id) public virtual async Task DeleteAsync(Guid id)
{ {
await _blogManagementAppService.DeleteAsync(id); await _blogManagementAppService.DeleteAsync(id);
} }
[HttpGet] [HttpGet]
[Route("clear-cache/{id}")] [Route("clear-cache/{id}")]
public async Task ClearCacheAsync(Guid id) public virtual async Task ClearCacheAsync(Guid id)
{ {
await _blogManagementAppService.ClearCacheAsync(id); await _blogManagementAppService.ClearCacheAsync(id);
} }

6
modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs

@ -18,7 +18,7 @@ namespace Volo.Blogging.Blogs
BlogRepository = blogRepository; BlogRepository = blogRepository;
} }
public async Task<ListResultDto<BlogDto>> GetListAsync() public virtual async Task<ListResultDto<BlogDto>> GetListAsync()
{ {
var blogs = await BlogRepository.GetListAsync(); var blogs = await BlogRepository.GetListAsync();
@ -27,7 +27,7 @@ namespace Volo.Blogging.Blogs
); );
} }
public async Task<BlogDto> GetByShortNameAsync(string shortName) public virtual async Task<BlogDto> GetByShortNameAsync(string shortName)
{ {
Check.NotNullOrWhiteSpace(shortName, nameof(shortName)); Check.NotNullOrWhiteSpace(shortName, nameof(shortName));
@ -41,7 +41,7 @@ namespace Volo.Blogging.Blogs
return ObjectMapper.Map<Blog, BlogDto>(blog); return ObjectMapper.Map<Blog, BlogDto>(blog);
} }
public async Task<BlogDto> GetAsync(Guid id) public virtual async Task<BlogDto> GetAsync(Guid id)
{ {
var blog = await BlogRepository.GetAsync(id); var blog = await BlogRepository.GetAsync(id);

8
modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Comments/CommentAppService.cs

@ -23,7 +23,7 @@ namespace Volo.Blogging.Comments
UserLookupService = userLookupService; UserLookupService = userLookupService;
} }
public async Task<List<CommentWithRepliesDto>> GetHierarchicalListOfPostAsync(Guid postId) public virtual async Task<List<CommentWithRepliesDto>> GetHierarchicalListOfPostAsync(Guid postId)
{ {
var comments = await GetListOfPostAsync(postId); var comments = await GetListOfPostAsync(postId);
var userDictionary = new Dictionary<Guid, BlogUserDto>(); var userDictionary = new Dictionary<Guid, BlogUserDto>();
@ -79,7 +79,7 @@ namespace Volo.Blogging.Comments
} }
[Authorize] [Authorize]
public async Task<CommentWithDetailsDto> CreateAsync(CreateCommentDto input) public virtual async Task<CommentWithDetailsDto> CreateAsync(CreateCommentDto input)
{ {
var comment = new Comment(GuidGenerator.Create(), input.PostId, input.RepliedCommentId, input.Text); var comment = new Comment(GuidGenerator.Create(), input.PostId, input.RepliedCommentId, input.Text);
@ -91,7 +91,7 @@ namespace Volo.Blogging.Comments
} }
[Authorize] [Authorize]
public async Task<CommentWithDetailsDto> UpdateAsync(Guid id, UpdateCommentDto input) public virtual async Task<CommentWithDetailsDto> UpdateAsync(Guid id, UpdateCommentDto input)
{ {
var comment = await CommentRepository.GetAsync(id); var comment = await CommentRepository.GetAsync(id);
@ -106,7 +106,7 @@ namespace Volo.Blogging.Comments
} }
[Authorize] [Authorize]
public async Task DeleteAsync(Guid id) public virtual async Task DeleteAsync(Guid id)
{ {
var comment = await CommentRepository.GetAsync(id); var comment = await CommentRepository.GetAsync(id);

4
modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs

@ -15,7 +15,7 @@ public class MemberAppService : BloggingAppServiceBase, IMemberAppService
_userRepository = userRepository; _userRepository = userRepository;
} }
public async Task<BlogUserDto> FindAsync(string username) public virtual async Task<BlogUserDto> FindAsync(string username)
{ {
var user = await _userRepository.FindAsync(x => x.UserName == username); var user = await _userRepository.FindAsync(x => x.UserName == username);
@ -27,7 +27,7 @@ public class MemberAppService : BloggingAppServiceBase, IMemberAppService
return ObjectMapper.Map<BlogUser, BlogUserDto>(user); return ObjectMapper.Map<BlogUser, BlogUserDto>(user);
} }
public async Task UpdateUserProfileAsync(CustomIdentityBlogUserUpdateDto input) public virtual async Task UpdateUserProfileAsync(CustomIdentityBlogUserUpdateDto input)
{ {
var user = await _userRepository.GetAsync(CurrentUser.Id.Value); var user = await _userRepository.GetAsync(CurrentUser.Id.Value);

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

@ -42,7 +42,7 @@ namespace Volo.Blogging.Posts
LocalEventBus = localEventBus; LocalEventBus = localEventBus;
} }
public async Task<ListResultDto<PostWithDetailsDto>> GetListByBlogIdAndTagNameAsync(Guid id, string tagName) public virtual async Task<ListResultDto<PostWithDetailsDto>> GetListByBlogIdAndTagNameAsync(Guid id, string tagName)
{ {
var posts = await PostRepository.GetPostsByBlogId(id); var posts = await PostRepository.GetPostsByBlogId(id);
var tag = tagName.IsNullOrWhiteSpace() ? null : await TagRepository.FindByNameAsync(id, tagName); var tag = tagName.IsNullOrWhiteSpace() ? null : await TagRepository.FindByNameAsync(id, tagName);
@ -82,7 +82,7 @@ namespace Volo.Blogging.Posts
return new ListResultDto<PostWithDetailsDto>(postDtos); return new ListResultDto<PostWithDetailsDto>(postDtos);
} }
public async Task<ListResultDto<PostWithDetailsDto>> GetTimeOrderedListAsync(Guid blogId) public virtual async Task<ListResultDto<PostWithDetailsDto>> GetTimeOrderedListAsync(Guid blogId)
{ {
var postCacheItems = await PostsCache.GetOrAddAsync( var postCacheItems = await PostsCache.GetOrAddAsync(
blogId.ToString(), blogId.ToString(),
@ -110,7 +110,7 @@ namespace Volo.Blogging.Posts
return new ListResultDto<PostWithDetailsDto>(postsWithDetails); return new ListResultDto<PostWithDetailsDto>(postsWithDetails);
} }
public async Task<PostWithDetailsDto> GetForReadingAsync(GetPostInput input) public virtual async Task<PostWithDetailsDto> GetForReadingAsync(GetPostInput input)
{ {
var post = await PostRepository.GetPostByUrl(input.BlogId, input.Url); var post = await PostRepository.GetPostByUrl(input.BlogId, input.Url);
@ -130,7 +130,7 @@ namespace Volo.Blogging.Posts
return postDto; return postDto;
} }
public async Task<PostWithDetailsDto> GetAsync(Guid id) public virtual async Task<PostWithDetailsDto> GetAsync(Guid id)
{ {
var post = await PostRepository.GetAsync(id); var post = await PostRepository.GetAsync(id);
@ -149,7 +149,7 @@ namespace Volo.Blogging.Posts
} }
[Authorize(BloggingPermissions.Posts.Delete)] [Authorize(BloggingPermissions.Posts.Delete)]
public async Task DeleteAsync(Guid id) public virtual async Task DeleteAsync(Guid id)
{ {
var post = await PostRepository.GetAsync(id); var post = await PostRepository.GetAsync(id);
@ -164,7 +164,7 @@ namespace Volo.Blogging.Posts
} }
[Authorize(BloggingPermissions.Posts.Update)] [Authorize(BloggingPermissions.Posts.Update)]
public async Task<PostWithDetailsDto> UpdateAsync(Guid id, UpdatePostDto input) public virtual async Task<PostWithDetailsDto> UpdateAsync(Guid id, UpdatePostDto input)
{ {
var post = await PostRepository.GetAsync(id); var post = await PostRepository.GetAsync(id);
@ -188,14 +188,14 @@ namespace Volo.Blogging.Posts
return ObjectMapper.Map<Post, PostWithDetailsDto>(post); return ObjectMapper.Map<Post, PostWithDetailsDto>(post);
} }
public async Task<List<PostWithDetailsDto>> GetListByUserIdAsync(Guid userId) public virtual async Task<List<PostWithDetailsDto>> GetListByUserIdAsync(Guid userId)
{ {
var posts = await PostRepository.GetListByUserIdAsync(userId); var posts = await PostRepository.GetListByUserIdAsync(userId);
return ObjectMapper.Map<List<Post>, List<PostWithDetailsDto>>(posts); return ObjectMapper.Map<List<Post>, List<PostWithDetailsDto>>(posts);
} }
public async Task<List<PostWithDetailsDto>> GetLatestBlogPostsAsync(Guid blogId, int count) public virtual async Task<List<PostWithDetailsDto>> GetLatestBlogPostsAsync(Guid blogId, int count)
{ {
var posts = await PostRepository.GetLatestBlogPostsAsync(blogId, count); var posts = await PostRepository.GetLatestBlogPostsAsync(blogId, count);
var userDictionary = new Dictionary<Guid, BlogUserDto>(); var userDictionary = new Dictionary<Guid, BlogUserDto>();
@ -226,7 +226,7 @@ namespace Volo.Blogging.Posts
} }
[Authorize(BloggingPermissions.Posts.Create)] [Authorize(BloggingPermissions.Posts.Create)]
public async Task<PostWithDetailsDto> CreateAsync(CreatePostDto input) public virtual async Task<PostWithDetailsDto> CreateAsync(CreatePostDto input)
{ {
input.Url = await RenameUrlIfItAlreadyExistAsync(input.BlogId, input.Url); input.Url = await RenameUrlIfItAlreadyExistAsync(input.BlogId, input.Url);

2
modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Tagging/TagAppService.cs

@ -15,7 +15,7 @@ namespace Volo.Blogging.Tagging
TagRepository = tagRepository; TagRepository = tagRepository;
} }
public async Task<List<TagDto>> GetPopularTagsAsync(Guid blogId, GetPopularTagsInput input) public virtual async Task<List<TagDto>> GetPopularTagsAsync(Guid blogId, GetPopularTagsInput input)
{ {
var postTags = (await TagRepository.GetListAsync(blogId)).OrderByDescending(t=>t.UsageCount) var postTags = (await TagRepository.GetListAsync(blogId)).OrderByDescending(t=>t.UsageCount)
.WhereIf(input.MinimumPostCount != null, t=>t.UsageCount >= input.MinimumPostCount) .WhereIf(input.MinimumPostCount != null, t=>t.UsageCount >= input.MinimumPostCount)

2
modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Blogs/EfCoreBlogRepository.cs

@ -16,7 +16,7 @@ namespace Volo.Blogging.Blogs
} }
public async Task<Blog> FindByShortNameAsync(string shortName, CancellationToken cancellationToken = default) public virtual async Task<Blog> FindByShortNameAsync(string shortName, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()).FirstOrDefaultAsync(p => p.ShortName == shortName, GetCancellationToken(cancellationToken)); return await (await GetDbSetAsync()).FirstOrDefaultAsync(p => p.ShortName == shortName, GetCancellationToken(cancellationToken));
} }

8
modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Comments/EfCoreCommentRepository.cs

@ -17,7 +17,7 @@ namespace Volo.Blogging.Comments
{ {
} }
public async Task<List<Comment>> GetListOfPostAsync(Guid postId, CancellationToken cancellationToken = default) public virtual async Task<List<Comment>> GetListOfPostAsync(Guid postId, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.Where(a => a.PostId == postId) .Where(a => a.PostId == postId)
@ -25,19 +25,19 @@ namespace Volo.Blogging.Comments
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<int> GetCommentCountOfPostAsync(Guid postId, CancellationToken cancellationToken = default) public virtual async Task<int> GetCommentCountOfPostAsync(Guid postId, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.CountAsync(a => a.PostId == postId, GetCancellationToken(cancellationToken)); .CountAsync(a => a.PostId == postId, GetCancellationToken(cancellationToken));
} }
public async Task<List<Comment>> GetRepliesOfComment(Guid id, CancellationToken cancellationToken = default) public virtual async Task<List<Comment>> GetRepliesOfComment(Guid id, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.Where(a => a.RepliedCommentId == id).ToListAsync(GetCancellationToken(cancellationToken)); .Where(a => a.RepliedCommentId == id).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task DeleteOfPost(Guid id, CancellationToken cancellationToken = default) public virtual async Task DeleteOfPost(Guid id, CancellationToken cancellationToken = default)
{ {
var recordsToDelete = await (await GetDbSetAsync()).Where(pt => pt.PostId == id).ToListAsync(GetCancellationToken(cancellationToken)); var recordsToDelete = await (await GetDbSetAsync()).Where(pt => pt.PostId == id).ToListAsync(GetCancellationToken(cancellationToken));
(await GetDbSetAsync()).RemoveRange(recordsToDelete); (await GetDbSetAsync()).RemoveRange(recordsToDelete);

12
modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs

@ -20,12 +20,12 @@ namespace Volo.Blogging.Posts
} }
public async Task<List<Post>> GetPostsByBlogId(Guid id, CancellationToken cancellationToken = default) public virtual async Task<List<Post>> GetPostsByBlogId(Guid id, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()).Where(p => p.BlogId == id).OrderByDescending(p=>p.CreationTime).ToListAsync(GetCancellationToken(cancellationToken)); return await (await GetDbSetAsync()).Where(p => p.BlogId == id).OrderByDescending(p=>p.CreationTime).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<bool> IsPostUrlInUseAsync(Guid blogId, string url, Guid? excludingPostId = null, CancellationToken cancellationToken = default) public virtual async Task<bool> IsPostUrlInUseAsync(Guid blogId, string url, Guid? excludingPostId = null, CancellationToken cancellationToken = default)
{ {
var query = (await GetDbSetAsync()).Where(p => blogId == p.BlogId && p.Url == url); var query = (await GetDbSetAsync()).Where(p => blogId == p.BlogId && p.Url == url);
@ -37,7 +37,7 @@ namespace Volo.Blogging.Posts
return await query.AnyAsync(GetCancellationToken(cancellationToken)); return await query.AnyAsync(GetCancellationToken(cancellationToken));
} }
public async Task<Post> GetPostByUrl(Guid blogId, string url, CancellationToken cancellationToken = default) public virtual async Task<Post> GetPostByUrl(Guid blogId, string url, CancellationToken cancellationToken = default)
{ {
var post = await (await GetDbSetAsync()).FirstOrDefaultAsync(p => p.BlogId == blogId && p.Url == url, GetCancellationToken(cancellationToken)); var post = await (await GetDbSetAsync()).FirstOrDefaultAsync(p => p.BlogId == blogId && p.Url == url, GetCancellationToken(cancellationToken));
@ -49,7 +49,7 @@ namespace Volo.Blogging.Posts
return post; return post;
} }
public async Task<List<Post>> GetOrderedList(Guid blogId,bool descending = false, CancellationToken cancellationToken = default) public virtual async Task<List<Post>> GetOrderedList(Guid blogId,bool descending = false, CancellationToken cancellationToken = default)
{ {
if (!descending) if (!descending)
{ {
@ -62,7 +62,7 @@ namespace Volo.Blogging.Posts
} }
public async Task<List<Post>> GetListByUserIdAsync(Guid userId, CancellationToken cancellationToken = default) public virtual async Task<List<Post>> GetListByUserIdAsync(Guid userId, CancellationToken cancellationToken = default)
{ {
var query = (await GetDbSetAsync()).Where(p => p.CreatorId == userId) var query = (await GetDbSetAsync()).Where(p => p.CreatorId == userId)
.OrderByDescending(p => p.CreationTime); .OrderByDescending(p => p.CreationTime);
@ -70,7 +70,7 @@ namespace Volo.Blogging.Posts
return await query.ToListAsync(GetCancellationToken(cancellationToken)); return await query.ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<Post>> GetLatestBlogPostsAsync(Guid blogId, int count, CancellationToken cancellationToken = default) public virtual async Task<List<Post>> GetLatestBlogPostsAsync(Guid blogId, int count, CancellationToken cancellationToken = default)
{ {
var query = (await GetDbSetAsync()).Where(p => p.BlogId == blogId) var query = (await GetDbSetAsync()).Where(p => p.BlogId == blogId)
.OrderByDescending(p => p.CreationTime) .OrderByDescending(p => p.CreationTime)

10
modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Tagging/EfCoreTagRepository.cs

@ -17,27 +17,27 @@ namespace Volo.Blogging.Tagging
{ {
} }
public async Task<List<Tag>> GetListAsync(Guid blogId, CancellationToken cancellationToken = default) public virtual async Task<List<Tag>> GetListAsync(Guid blogId, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()).Where(t=>t.BlogId == blogId).ToListAsync(GetCancellationToken(cancellationToken)); return await (await GetDbSetAsync()).Where(t=>t.BlogId == blogId).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<Tag> GetByNameAsync(Guid blogId, string name, CancellationToken cancellationToken = default) public virtual async Task<Tag> GetByNameAsync(Guid blogId, string name, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()).FirstAsync(t=> t.BlogId == blogId && t.Name == name, GetCancellationToken(cancellationToken)); return await (await GetDbSetAsync()).FirstAsync(t=> t.BlogId == blogId && t.Name == name, GetCancellationToken(cancellationToken));
} }
public async Task<Tag> FindByNameAsync(Guid blogId, string name, CancellationToken cancellationToken = default) public virtual async Task<Tag> FindByNameAsync(Guid blogId, string name, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()).FirstOrDefaultAsync(t => t.BlogId == blogId && t.Name == name, GetCancellationToken(cancellationToken)); return await (await GetDbSetAsync()).FirstOrDefaultAsync(t => t.BlogId == blogId && t.Name == name, GetCancellationToken(cancellationToken));
} }
public async Task<List<Tag>> GetListAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default) public virtual async Task<List<Tag>> GetListAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()).Where(t => ids.Contains(t.Id)).ToListAsync(GetCancellationToken(cancellationToken)); return await (await GetDbSetAsync()).Where(t => ids.Contains(t.Id)).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task DecreaseUsageCountOfTagsAsync(List<Guid> ids, CancellationToken cancellationToken = default) public virtual async Task DecreaseUsageCountOfTagsAsync(List<Guid> ids, CancellationToken cancellationToken = default)
{ {
var tags = await (await GetDbSetAsync()) var tags = await (await GetDbSetAsync())
.Where(t => ids.Any(id => id == t.Id)) .Where(t => ids.Any(id => id == t.Id))

2
modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Users/EfCoreBlogUserRepository.cs

@ -17,7 +17,7 @@ namespace Volo.Blogging.Users
} }
public async Task<List<BlogUser>> GetUsersAsync(int maxCount, string filter, CancellationToken cancellationToken = default) public virtual async Task<List<BlogUser>> GetUsersAsync(int maxCount, string filter, CancellationToken cancellationToken = default)
{ {
return await DbSet return await DbSet
.WhereIf( !string.IsNullOrWhiteSpace( filter), x=>x.UserName.Contains(filter)) .WhereIf( !string.IsNullOrWhiteSpace( filter), x=>x.UserName.Contains(filter))

2
modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogFilesController.cs

@ -28,7 +28,7 @@ namespace Volo.Blogging
[HttpGet] [HttpGet]
[Route("www/{name}")] [Route("www/{name}")]
public async Task<IRemoteStreamContent> GetFileAsync(string name) public virtual async Task<IRemoteStreamContent> GetFileAsync(string name)
{ {
return await _fileAppService.GetFileAsync(name); return await _fileAppService.GetFileAsync(name);
} }

6
modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs

@ -22,21 +22,21 @@ namespace Volo.Blogging
} }
[HttpGet] [HttpGet]
public async Task<ListResultDto<BlogDto>> GetListAsync() public virtual async Task<ListResultDto<BlogDto>> GetListAsync()
{ {
return await _blogAppService.GetListAsync(); return await _blogAppService.GetListAsync();
} }
[HttpGet] [HttpGet]
[Route("by-shortname/{shortName}")] [Route("by-shortname/{shortName}")]
public async Task<BlogDto> GetByShortNameAsync(string shortName) public virtual async Task<BlogDto> GetByShortNameAsync(string shortName)
{ {
return await _blogAppService.GetByShortNameAsync(shortName); return await _blogAppService.GetByShortNameAsync(shortName);
} }
[HttpGet] [HttpGet]
[Route("{id}")] [Route("{id}")]
public async Task<BlogDto> GetAsync(Guid id) public virtual async Task<BlogDto> GetAsync(Guid id)
{ {
return await _blogAppService.GetAsync(id); return await _blogAppService.GetAsync(id);
} }

2
modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Blogs/MongoBlogRepository.cs

@ -14,7 +14,7 @@ namespace Volo.Blogging.Blogs
{ {
} }
public async Task<Blog> FindByShortNameAsync(string shortName, CancellationToken cancellationToken = default) public virtual async Task<Blog> FindByShortNameAsync(string shortName, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)).FirstOrDefaultAsync(p => p.ShortName == shortName, GetCancellationToken(cancellationToken)); return await (await GetMongoQueryableAsync(cancellationToken)).FirstOrDefaultAsync(p => p.ShortName == shortName, GetCancellationToken(cancellationToken));
} }

8
modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Comments/MongoCommentRepository.cs

@ -16,7 +16,7 @@ namespace Volo.Blogging.Comments
{ {
} }
public async Task<List<Comment>> GetListOfPostAsync(Guid postId, CancellationToken cancellationToken = default) public virtual async Task<List<Comment>> GetListOfPostAsync(Guid postId, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.Where(a => a.PostId == postId) .Where(a => a.PostId == postId)
@ -24,19 +24,19 @@ namespace Volo.Blogging.Comments
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<int> GetCommentCountOfPostAsync(Guid postId, CancellationToken cancellationToken = default) public virtual async Task<int> GetCommentCountOfPostAsync(Guid postId, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.CountAsync(a => a.PostId == postId, GetCancellationToken(cancellationToken)); .CountAsync(a => a.PostId == postId, GetCancellationToken(cancellationToken));
} }
public async Task<List<Comment>> GetRepliesOfComment(Guid id, CancellationToken cancellationToken = default) public virtual async Task<List<Comment>> GetRepliesOfComment(Guid id, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.Where(a => a.RepliedCommentId == id).ToListAsync(GetCancellationToken(cancellationToken)); .Where(a => a.RepliedCommentId == id).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task DeleteOfPost(Guid id, CancellationToken cancellationToken = default) public virtual async Task DeleteOfPost(Guid id, CancellationToken cancellationToken = default)
{ {
var recordsToDelete = (await GetMongoQueryableAsync(cancellationToken)).Where(pt => pt.PostId == id); var recordsToDelete = (await GetMongoQueryableAsync(cancellationToken)).Where(pt => pt.PostId == id);

12
modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs

@ -18,13 +18,13 @@ namespace Volo.Blogging.Posts
{ {
} }
public async Task<List<Post>> GetPostsByBlogId(Guid id, CancellationToken cancellationToken = default) public virtual async Task<List<Post>> GetPostsByBlogId(Guid id, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)).Where(p => p.BlogId == id).OrderByDescending(p => p.CreationTime).ToListAsync(GetCancellationToken(cancellationToken)); return await (await GetMongoQueryableAsync(cancellationToken)).Where(p => p.BlogId == id).OrderByDescending(p => p.CreationTime).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<bool> IsPostUrlInUseAsync(Guid blogId, string url, Guid? excludingPostId = null, CancellationToken cancellationToken = default) public virtual async Task<bool> IsPostUrlInUseAsync(Guid blogId, string url, Guid? excludingPostId = null, CancellationToken cancellationToken = default)
{ {
var query = (await GetMongoQueryableAsync(cancellationToken)).Where(p => blogId == p.BlogId && p.Url == url); var query = (await GetMongoQueryableAsync(cancellationToken)).Where(p => blogId == p.BlogId && p.Url == url);
@ -36,7 +36,7 @@ namespace Volo.Blogging.Posts
return await query.AnyAsync(GetCancellationToken(cancellationToken)); return await query.AnyAsync(GetCancellationToken(cancellationToken));
} }
public async Task<Post> GetPostByUrl(Guid blogId, string url, CancellationToken cancellationToken = default) public virtual async Task<Post> GetPostByUrl(Guid blogId, string url, CancellationToken cancellationToken = default)
{ {
var post = await (await GetMongoQueryableAsync(cancellationToken)).FirstOrDefaultAsync(p => p.BlogId == blogId && p.Url == url, GetCancellationToken(cancellationToken)); var post = await (await GetMongoQueryableAsync(cancellationToken)).FirstOrDefaultAsync(p => p.BlogId == blogId && p.Url == url, GetCancellationToken(cancellationToken));
@ -48,7 +48,7 @@ namespace Volo.Blogging.Posts
return post; return post;
} }
public async Task<List<Post>> GetOrderedList(Guid blogId, bool @descending = false, CancellationToken cancellationToken = default) public virtual async Task<List<Post>> GetOrderedList(Guid blogId, bool @descending = false, CancellationToken cancellationToken = default)
{ {
var query = (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.BlogId == blogId); var query = (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.BlogId == blogId);
@ -60,7 +60,7 @@ namespace Volo.Blogging.Posts
return await query.OrderByDescending(x => x.CreationTime).ToListAsync(GetCancellationToken(cancellationToken)); return await query.OrderByDescending(x => x.CreationTime).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<Post>> GetListByUserIdAsync(Guid userId, CancellationToken cancellationToken = default) public virtual async Task<List<Post>> GetListByUserIdAsync(Guid userId, CancellationToken cancellationToken = default)
{ {
var query = (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.CreatorId == userId) var query = (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.CreatorId == userId)
.OrderByDescending(x => x.CreationTime); .OrderByDescending(x => x.CreationTime);
@ -68,7 +68,7 @@ namespace Volo.Blogging.Posts
return await query.ToListAsync(GetCancellationToken(cancellationToken)); return await query.ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<Post>> GetLatestBlogPostsAsync(Guid blogId, int count, CancellationToken cancellationToken = default) public virtual async Task<List<Post>> GetLatestBlogPostsAsync(Guid blogId, int count, CancellationToken cancellationToken = default)
{ {
var query = (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.BlogId == blogId) var query = (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.BlogId == blogId)
.OrderByDescending(x => x.CreationTime) .OrderByDescending(x => x.CreationTime)

10
modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Tagging/MongoTagRepository.cs

@ -18,27 +18,27 @@ namespace Volo.Blogging.Tagging
{ {
} }
public async Task<List<Tag>> GetListAsync(Guid blogId, CancellationToken cancellationToken = default) public virtual async Task<List<Tag>> GetListAsync(Guid blogId, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)).Where(t => t.BlogId == blogId).ToListAsync(GetCancellationToken(cancellationToken)); return await (await GetMongoQueryableAsync(cancellationToken)).Where(t => t.BlogId == blogId).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<Tag> GetByNameAsync(Guid blogId, string name, CancellationToken cancellationToken = default) public virtual async Task<Tag> GetByNameAsync(Guid blogId, string name, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)).Where(t => t.BlogId == blogId && t.Name == name).FirstAsync(GetCancellationToken(cancellationToken)); return await (await GetMongoQueryableAsync(cancellationToken)).Where(t => t.BlogId == blogId && t.Name == name).FirstAsync(GetCancellationToken(cancellationToken));
} }
public async Task<Tag> FindByNameAsync(Guid blogId, string name, CancellationToken cancellationToken = default) public virtual async Task<Tag> FindByNameAsync(Guid blogId, string name, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)).Where(t => t.BlogId == blogId && t.Name == name).FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); return await (await GetMongoQueryableAsync(cancellationToken)).Where(t => t.BlogId == blogId && t.Name == name).FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<Tag>> GetListAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default) public virtual async Task<List<Tag>> GetListAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)).Where(t => ids.Contains(t.Id)).ToListAsync(GetCancellationToken(cancellationToken)); return await (await GetMongoQueryableAsync(cancellationToken)).Where(t => ids.Contains(t.Id)).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task DecreaseUsageCountOfTagsAsync(List<Guid> ids, CancellationToken cancellationToken = default) public virtual async Task DecreaseUsageCountOfTagsAsync(List<Guid> ids, CancellationToken cancellationToken = default)
{ {
var tags = await (await GetMongoQueryableAsync(cancellationToken)) var tags = await (await GetMongoQueryableAsync(cancellationToken))
.Where(t => ids.Contains(t.Id)) .Where(t => ids.Contains(t.Id))

2
modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Users/MongoBlogUserRepository.cs

@ -15,7 +15,7 @@ namespace Volo.Blogging.Users
{ {
} }
public async Task<List<BlogUser>> GetUsersAsync(int maxCount, string filter, CancellationToken cancellationToken = default) public virtual async Task<List<BlogUser>> GetUsersAsync(int maxCount, string filter, CancellationToken cancellationToken = default)
{ {
var query = await GetMongoQueryableAsync(cancellationToken); var query = await GetMongoQueryableAsync(cancellationToken);

4
modules/blogging/src/Volo.Blogging.Web/Areas/Blog/Controllers/CommentsController.cs

@ -22,13 +22,13 @@ namespace Volo.Blogging.Areas.Blog.Controllers
} }
[HttpPost] [HttpPost]
public async Task Delete(Guid id) public virtual async Task Delete(Guid id)
{ {
await _commentAppService.DeleteAsync(id); await _commentAppService.DeleteAsync(id);
} }
[HttpPost] [HttpPost]
public async Task Update(Guid id, UpdateCommentDto commentDto) public virtual async Task Update(Guid id, UpdateCommentDto commentDto)
{ {
await _commentAppService.UpdateAsync(id, commentDto); await _commentAppService.UpdateAsync(id, commentDto);
} }

2
modules/blogging/src/Volo.Blogging.Web/Areas/Blog/Controllers/PostsController.cs

@ -20,7 +20,7 @@ namespace Volo.Blogging.Areas.Blog.Controllers
} }
[HttpPost] [HttpPost]
public async Task Delete(Guid id) public virtual async Task Delete(Guid id)
{ {
await _postAppService.DeleteAsync(id); await _postAppService.DeleteAsync(id);
} }

2
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs

@ -177,7 +177,7 @@ public class BlogPostAdminAppService : CmsKitAppServiceBase, IBlogPostAdminAppSe
} }
[Authorize(CmsKitAdminPermissions.BlogPosts.Publish)] [Authorize(CmsKitAdminPermissions.BlogPosts.Publish)]
public async Task<bool> HasBlogPostWaitingForReviewAsync() public virtual async Task<bool> HasBlogPostWaitingForReviewAsync()
{ {
return await BlogPostRepository.HasBlogPostWaitingForReviewAsync(); return await BlogPostRepository.HasBlogPostWaitingForReviewAsync();
} }

4
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/GlobalResources/GlobalResourceAdminAppService.cs

@ -22,7 +22,7 @@ public class GlobalResourceAdminAppService : ApplicationService, IGlobalResource
GlobalResourceManager = globalResourceManager; GlobalResourceManager = globalResourceManager;
} }
public async Task<GlobalResourcesDto> GetAsync() public virtual async Task<GlobalResourcesDto> GetAsync()
{ {
return new GlobalResourcesDto return new GlobalResourcesDto
{ {
@ -31,7 +31,7 @@ public class GlobalResourceAdminAppService : ApplicationService, IGlobalResource
}; };
} }
public async Task SetGlobalResourcesAsync(GlobalResourcesUpdateDto input) public virtual async Task SetGlobalResourcesAsync(GlobalResourcesUpdateDto input)
{ {
await GlobalResourceManager.SetGlobalStyleAsync(input.Style); await GlobalResourceManager.SetGlobalStyleAsync(input.Style);
await GlobalResourceManager.SetGlobalScriptAsync(input.Script); await GlobalResourceManager.SetGlobalScriptAsync(input.Script);

10
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/TagAdminAppService.cs

@ -39,7 +39,7 @@ public class TagAdminAppService : CmsKitAppServiceBase, ITagAdminAppService
} }
[Authorize(CmsKitAdminPermissions.Tags.Create)] [Authorize(CmsKitAdminPermissions.Tags.Create)]
public async Task<TagDto> CreateAsync(TagCreateDto input) public virtual async Task<TagDto> CreateAsync(TagCreateDto input)
{ {
var tag = await TagManager.CreateAsync( var tag = await TagManager.CreateAsync(
GuidGenerator.Create(), GuidGenerator.Create(),
@ -52,7 +52,7 @@ public class TagAdminAppService : CmsKitAppServiceBase, ITagAdminAppService
} }
[Authorize(CmsKitAdminPermissions.Tags.Update)] [Authorize(CmsKitAdminPermissions.Tags.Update)]
public async Task<TagDto> UpdateAsync(Guid id, TagUpdateDto input) public virtual async Task<TagDto> UpdateAsync(Guid id, TagUpdateDto input)
{ {
var tag = await TagManager.UpdateAsync( var tag = await TagManager.UpdateAsync(
id, id,
@ -82,7 +82,7 @@ public class TagAdminAppService : CmsKitAppServiceBase, ITagAdminAppService
} }
[Authorize(CmsKitAdminPermissions.Tags.Default)] [Authorize(CmsKitAdminPermissions.Tags.Default)]
public async Task<TagDto> GetAsync(Guid id) public virtual async Task<TagDto> GetAsync(Guid id)
{ {
var tag = await Repository.GetAsync(id); var tag = await Repository.GetAsync(id);
@ -90,7 +90,7 @@ public class TagAdminAppService : CmsKitAppServiceBase, ITagAdminAppService
} }
[Authorize(CmsKitAdminPermissions.Tags.Default)] [Authorize(CmsKitAdminPermissions.Tags.Default)]
public async Task<PagedResultDto<TagDto>> GetListAsync(TagGetListInput input) public virtual async Task<PagedResultDto<TagDto>> GetListAsync(TagGetListInput input)
{ {
var tags = await Repository.GetListAsync(input.Filter); var tags = await Repository.GetListAsync(input.Filter);
var count = await Repository.GetCountAsync(input.Filter); var count = await Repository.GetCountAsync(input.Filter);
@ -102,7 +102,7 @@ public class TagAdminAppService : CmsKitAppServiceBase, ITagAdminAppService
} }
[Authorize(CmsKitAdminPermissions.Tags.Delete)] [Authorize(CmsKitAdminPermissions.Tags.Delete)]
public async Task DeleteAsync(Guid id) public virtual async Task DeleteAsync(Guid id)
{ {
await Repository.DeleteAsync(id); await Repository.DeleteAsync(id);
} }

4
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogFeatureRepository.cs

@ -21,14 +21,14 @@ public class EfCoreBlogFeatureRepository : EfCoreRepository<ICmsKitDbContext, Bl
return base.FindAsync(x => x.BlogId == blogId && x.FeatureName == featureName, cancellationToken: cancellationToken); return base.FindAsync(x => x.BlogId == blogId && x.FeatureName == featureName, cancellationToken: cancellationToken);
} }
public async Task<List<BlogFeature>> GetListAsync(Guid blogId, CancellationToken cancellationToken = default) public virtual async Task<List<BlogFeature>> GetListAsync(Guid blogId, CancellationToken cancellationToken = default)
{ {
return await (await GetQueryableAsync()) return await (await GetQueryableAsync())
.Where(x => x.BlogId == blogId) .Where(x => x.BlogId == blogId)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<BlogFeature>> GetListAsync(Guid blogId, List<string> featureNames, CancellationToken cancellationToken = default) public virtual async Task<List<BlogFeature>> GetListAsync(Guid blogId, List<string> featureNames, CancellationToken cancellationToken = default)
{ {
return await (await GetQueryableAsync()) return await (await GetQueryableAsync())
.Where(x => x.BlogId == blogId && featureNames.Contains(x.FeatureName)) .Where(x => x.BlogId == blogId && featureNames.Contains(x.FeatureName))

10
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs

@ -27,7 +27,7 @@ public class EfCoreBlogPostRepository : EfCoreRepository<ICmsKitDbContext, BlogP
_entityTagManager = entityTagManager; _entityTagManager = entityTagManager;
} }
public async Task<BlogPost> GetBySlugAsync( public virtual async Task<BlogPost> GetBySlugAsync(
Guid blogId, Guid blogId,
[NotNull] string slug, [NotNull] string slug,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
@ -118,7 +118,7 @@ public class EfCoreBlogPostRepository : EfCoreRepository<ICmsKitDbContext, BlogP
}).ToList(); }).ToList();
} }
public async Task<bool> SlugExistsAsync(Guid blogId, [NotNull] string slug, public virtual async Task<bool> SlugExistsAsync(Guid blogId, [NotNull] string slug,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
Check.NotNullOrEmpty(slug, nameof(slug)); Check.NotNullOrEmpty(slug, nameof(slug));
@ -127,7 +127,7 @@ public class EfCoreBlogPostRepository : EfCoreRepository<ICmsKitDbContext, BlogP
GetCancellationToken(cancellationToken)); GetCancellationToken(cancellationToken));
} }
public async Task<List<CmsUser>> GetAuthorsHasBlogPostsAsync(int skipCount, int maxResultCount, string sorting, string filter, CancellationToken cancellationToken = default) public virtual async Task<List<CmsUser>> GetAuthorsHasBlogPostsAsync(int skipCount, int maxResultCount, string sorting, string filter, CancellationToken cancellationToken = default)
{ {
return await (await CreateAuthorsQueryableAsync()) return await (await CreateAuthorsQueryableAsync())
.Skip(skipCount) .Skip(skipCount)
@ -137,14 +137,14 @@ public class EfCoreBlogPostRepository : EfCoreRepository<ICmsKitDbContext, BlogP
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<int> GetAuthorsHasBlogPostsCountAsync(string filter, CancellationToken cancellationToken = default) public virtual async Task<int> GetAuthorsHasBlogPostsCountAsync(string filter, CancellationToken cancellationToken = default)
{ {
return await (await CreateAuthorsQueryableAsync()) return await (await CreateAuthorsQueryableAsync())
.WhereIf(!filter.IsNullOrEmpty(), x => x.UserName.Contains(filter.ToLower())) .WhereIf(!filter.IsNullOrEmpty(), x => x.UserName.Contains(filter.ToLower()))
.CountAsync(GetCancellationToken(cancellationToken)); .CountAsync(GetCancellationToken(cancellationToken));
} }
public async Task<CmsUser> GetAuthorHasBlogPostAsync(Guid id, CancellationToken cancellationToken = default) public virtual async Task<CmsUser> GetAuthorHasBlogPostAsync(Guid id, CancellationToken cancellationToken = default)
{ {
return await (await CreateAuthorsQueryableAsync()).FirstOrDefaultAsync(x => x.Id == id, GetCancellationToken(cancellationToken)) return await (await CreateAuthorsQueryableAsync()).FirstOrDefaultAsync(x => x.Id == id, GetCancellationToken(cancellationToken))
?? throw new EntityNotFoundException(typeof(CmsUser), id); ?? throw new EntityNotFoundException(typeof(CmsUser), id);

10
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs

@ -22,7 +22,7 @@ public class EfCoreCommentRepository : EfCoreRepository<ICmsKitDbContext, Commen
{ {
} }
public async Task<CommentWithAuthorQueryResultItem> GetWithAuthorAsync(Guid id, public virtual async Task<CommentWithAuthorQueryResultItem> GetWithAuthorAsync(Guid id,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var query = from comment in (await GetDbSetAsync()) var query = from comment in (await GetDbSetAsync())
@ -44,7 +44,7 @@ public class EfCoreCommentRepository : EfCoreRepository<ICmsKitDbContext, Commen
return commentWithAuthor; return commentWithAuthor;
} }
public async Task<List<CommentWithAuthorQueryResultItem>> GetListAsync( public virtual async Task<List<CommentWithAuthorQueryResultItem>> GetListAsync(
string filter = null, string filter = null,
string entityType = null, string entityType = null,
Guid? repliedCommentId = null, Guid? repliedCommentId = null,
@ -78,7 +78,7 @@ public class EfCoreCommentRepository : EfCoreRepository<ICmsKitDbContext, Commen
return await query.ToListAsync(token); return await query.ToListAsync(token);
} }
public async Task<long> GetCountAsync( public virtual async Task<long> GetCountAsync(
string text = null, string text = null,
string entityType = null, string entityType = null,
Guid? repliedCommentId = null, Guid? repliedCommentId = null,
@ -101,7 +101,7 @@ public class EfCoreCommentRepository : EfCoreRepository<ICmsKitDbContext, Commen
return await query.LongCountAsync(token); return await query.LongCountAsync(token);
} }
public async Task<List<CommentWithAuthorQueryResultItem>> GetListWithAuthorsAsync( public virtual async Task<List<CommentWithAuthorQueryResultItem>> GetListWithAuthorsAsync(
string entityType, string entityType,
string entityId, string entityId,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
@ -122,7 +122,7 @@ public class EfCoreCommentRepository : EfCoreRepository<ICmsKitDbContext, Commen
return await query.ToListAsync(GetCancellationToken(cancellationToken)); return await query.ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task DeleteWithRepliesAsync( public virtual async Task DeleteWithRepliesAsync(
Comment comment, Comment comment,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {

4
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Ratings/EfCoreRatingRepository.cs

@ -18,7 +18,7 @@ public class EfCoreRatingRepository : EfCoreRepository<ICmsKitDbContext, Rating,
{ {
} }
public async Task<Rating> GetCurrentUserRatingAsync(string entityType, string entityId, Guid userId, public virtual async Task<Rating> GetCurrentUserRatingAsync(string entityType, string entityId, Guid userId,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
@ -31,7 +31,7 @@ public class EfCoreRatingRepository : EfCoreRepository<ICmsKitDbContext, Rating,
return rating; return rating;
} }
public async Task<List<RatingWithStarCountQueryResultItem>> GetGroupedStarCountsAsync(string entityType, public virtual async Task<List<RatingWithStarCountQueryResultItem>> GetGroupedStarCountsAsync(string entityType,
string entityId, CancellationToken cancellationToken = default) string entityId, CancellationToken cancellationToken = default)
{ {
Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityType, nameof(entityType));

6
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs

@ -19,7 +19,7 @@ public class EfCoreUserReactionRepository : EfCoreRepository<ICmsKitDbContext, U
{ {
} }
public async Task<UserReaction> FindAsync( public virtual async Task<UserReaction> FindAsync(
Guid userId, Guid userId,
string entityType, string entityType,
string entityId, string entityId,
@ -39,7 +39,7 @@ public class EfCoreUserReactionRepository : EfCoreRepository<ICmsKitDbContext, U
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<UserReaction>> GetListForUserAsync( public virtual async Task<List<UserReaction>> GetListForUserAsync(
Guid userId, Guid userId,
string entityType, string entityType,
string entityId, string entityId,
@ -56,7 +56,7 @@ public class EfCoreUserReactionRepository : EfCoreRepository<ICmsKitDbContext, U
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<ReactionSummaryQueryResultItem>> GetSummariesAsync( public virtual async Task<List<ReactionSummaryQueryResultItem>> GetSummariesAsync(
string entityType, string entityType,
string entityId, string entityId,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)

2
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreEntityTagRepository.cs

@ -53,7 +53,7 @@ public class EfCoreEntityTagRepository : EfCoreRepository<ICmsKitDbContext, Enti
.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); .ToListAsync(cancellationToken: GetCancellationToken(cancellationToken));
} }
public async Task<List<string>> GetEntityIdsFilteredByTagNameAsync( public virtual async Task<List<string>> GetEntityIdsFilteredByTagNameAsync(
[NotNull] string tagName, [NotNull] string tagName,
[NotNull] string entityType, [NotNull] string entityType,
[CanBeNull] Guid? tenantId = null, [CanBeNull] Guid? tenantId = null,

4
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs

@ -80,12 +80,12 @@ public class EfCoreTagRepository : EfCoreRepository<ICmsKitDbContext, Tag, Guid>
return await query.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); return await query.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken));
} }
public async Task<List<Tag>> GetListAsync(string filter, CancellationToken cancellationToken = default) public virtual async Task<List<Tag>> GetListAsync(string filter, CancellationToken cancellationToken = default)
{ {
return await (await GetQueryableByFilterAsync(filter)).ToListAsync(GetCancellationToken(cancellationToken)); return await (await GetQueryableByFilterAsync(filter)).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<int> GetCountAsync(string filter, CancellationToken cancellationToken = default) public virtual async Task<int> GetCountAsync(string filter, CancellationToken cancellationToken = default)
{ {
return await (await GetQueryableByFilterAsync(filter)).CountAsync(GetCancellationToken(cancellationToken)); return await (await GetQueryableByFilterAsync(filter)).CountAsync(GetCancellationToken(cancellationToken));
} }

6
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs

@ -128,7 +128,7 @@ public class MongoBlogPostRepository : MongoDbRepository<CmsKitMongoDbContext, B
return await queryable.AnyAsync(x => x.BlogId == blogId && x.Slug.ToLower() == slug, cancellationToken); return await queryable.AnyAsync(x => x.BlogId == blogId && x.Slug.ToLower() == slug, cancellationToken);
} }
public async Task<List<CmsUser>> GetAuthorsHasBlogPostsAsync(int skipCount, int maxResultCount, string sorting, string filter, CancellationToken cancellationToken = default) public virtual async Task<List<CmsUser>> GetAuthorsHasBlogPostsAsync(int skipCount, int maxResultCount, string sorting, string filter, CancellationToken cancellationToken = default)
{ {
var queryable = (await CreateAuthorsQueryableAsync(cancellationToken)) var queryable = (await CreateAuthorsQueryableAsync(cancellationToken))
.Skip(skipCount) .Skip(skipCount)
@ -139,14 +139,14 @@ public class MongoBlogPostRepository : MongoDbRepository<CmsKitMongoDbContext, B
return await AsyncExecuter.ToListAsync(queryable, GetCancellationToken(cancellationToken)); return await AsyncExecuter.ToListAsync(queryable, GetCancellationToken(cancellationToken));
} }
public async Task<int> GetAuthorsHasBlogPostsCountAsync(string filter, CancellationToken cancellationToken = default) public virtual async Task<int> GetAuthorsHasBlogPostsCountAsync(string filter, CancellationToken cancellationToken = default)
{ {
return await AsyncExecuter.CountAsync( return await AsyncExecuter.CountAsync(
(await CreateAuthorsQueryableAsync(cancellationToken)) (await CreateAuthorsQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrEmpty(), x => x.UserName.Contains(filter.ToLower()))); .WhereIf(!filter.IsNullOrEmpty(), x => x.UserName.Contains(filter.ToLower())));
} }
public async Task<CmsUser> GetAuthorHasBlogPostAsync(Guid id, CancellationToken cancellationToken = default) public virtual async Task<CmsUser> GetAuthorHasBlogPostAsync(Guid id, CancellationToken cancellationToken = default)
{ {
return await AsyncExecuter.FirstOrDefaultAsync(await CreateAuthorsQueryableAsync(cancellationToken), x => x.Id == id) return await AsyncExecuter.FirstOrDefaultAsync(await CreateAuthorsQueryableAsync(cancellationToken), x => x.Id == id)
?? throw new EntityNotFoundException(typeof(CmsUser), id); ?? throw new EntityNotFoundException(typeof(CmsUser), id);

2
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoEntityTagRepository.cs

@ -60,7 +60,7 @@ public class MongoEntityTagRepository : MongoDbRepository<ICmsKitMongoDbContext,
return await AsyncExecuter.ToListAsync(blogPostQueryable, GetCancellationToken(cancellationToken)); return await AsyncExecuter.ToListAsync(blogPostQueryable, GetCancellationToken(cancellationToken));
} }
public async Task<List<string>> GetEntityIdsFilteredByTagNameAsync( public virtual async Task<List<string>> GetEntityIdsFilteredByTagNameAsync(
[NotNull] string tagName, [NotNull] string tagName,
[NotNull] string entityType, [NotNull] string entityType,
[CanBeNull] Guid? tenantId = null, [CanBeNull] Guid? tenantId = null,

6
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs

@ -19,7 +19,7 @@ public class MongoTagRepository : MongoDbRepository<ICmsKitMongoDbContext, Volo.
{ {
} }
public async Task<bool> AnyAsync( public virtual async Task<bool> AnyAsync(
[NotNull] string entityType, [NotNull] string entityType,
[NotNull] string name, [NotNull] string name,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
@ -82,12 +82,12 @@ public class MongoTagRepository : MongoDbRepository<ICmsKitMongoDbContext, Volo.
} }
public async Task<List<Tag>> GetListAsync(string filter, CancellationToken cancellationToken = default) public virtual async Task<List<Tag>> GetListAsync(string filter, CancellationToken cancellationToken = default)
{ {
return await (await GetQueryableByFilterAsync(filter, cancellationToken)).ToListAsync(GetCancellationToken(cancellationToken)); return await (await GetQueryableByFilterAsync(filter, cancellationToken)).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<int> GetCountAsync(string filter, CancellationToken cancellationToken = default) public virtual async Task<int> GetCountAsync(string filter, CancellationToken cancellationToken = default)
{ {
return await (await GetQueryableByFilterAsync(filter, cancellationToken)).CountAsync(GetCancellationToken(cancellationToken)); return await (await GetQueryableByFilterAsync(filter, cancellationToken)).CountAsync(GetCancellationToken(cancellationToken));
} }

4
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs

@ -66,7 +66,7 @@ public class BlogPostPublicAppService : CmsKitPublicAppServiceBase, IBlogPostPub
authorDtos); authorDtos);
} }
public async Task<CmsUserDto> GetAuthorHasBlogPostAsync(Guid id) public virtual async Task<CmsUserDto> GetAuthorHasBlogPostAsync(Guid id)
{ {
var author = await BlogPostRepository.GetAuthorHasBlogPostAsync(id); var author = await BlogPostRepository.GetAuthorHasBlogPostAsync(id);
@ -74,7 +74,7 @@ public class BlogPostPublicAppService : CmsKitPublicAppServiceBase, IBlogPostPub
} }
[Authorize] [Authorize]
public async Task DeleteAsync(Guid id) public virtual async Task DeleteAsync(Guid id)
{ {
var rating = await BlogPostRepository.GetAsync(id); var rating = await BlogPostRepository.GetAsync(id);

4
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/GlobalResources/GlobalResourcePublicAppService.cs

@ -19,14 +19,14 @@ public class GlobalResourcePublicAppService : ApplicationService, IGlobalResourc
GlobalResourceManager = globalResourceManager; GlobalResourceManager = globalResourceManager;
} }
public async Task<GlobalResourceDto> GetGlobalScriptAsync() public virtual async Task<GlobalResourceDto> GetGlobalScriptAsync()
{ {
var globalScript = await GlobalResourceManager.GetGlobalScriptAsync(); var globalScript = await GlobalResourceManager.GetGlobalScriptAsync();
return ObjectMapper.Map<GlobalResource, GlobalResourceDto>(globalScript); return ObjectMapper.Map<GlobalResource, GlobalResourceDto>(globalScript);
} }
public async Task<GlobalResourceDto> GetGlobalStyleAsync() public virtual async Task<GlobalResourceDto> GetGlobalStyleAsync()
{ {
var globalStyle = await GlobalResourceManager.GetGlobalStyleAsync(); var globalStyle = await GlobalResourceManager.GetGlobalStyleAsync();

2
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Menus/MenuItemPublicAppService.cs

@ -24,7 +24,7 @@ public class MenuItemPublicAppService : CmsKitPublicAppServiceBase, IMenuItemPub
DistributedCache = distributedCache; DistributedCache = distributedCache;
} }
public async Task<List<MenuItemDto>> GetListAsync() public virtual async Task<List<MenuItemDto>> GetListAsync()
{ {
var cachedMenu = await DistributedCache.GetOrAddAsync( var cachedMenu = await DistributedCache.GetOrAddAsync(
MenuApplicationConsts.MainMenuCacheKey, MenuApplicationConsts.MainMenuCacheKey,

2
modules/cms-kit/src/Volo.CmsKit.Public.Web/Controllers/CmsKitPublicCommentsController.cs

@ -29,7 +29,7 @@ public class CmsKitPublicCommentsController : AbpController
} }
[HttpPost] [HttpPost]
public async Task ValidateAsync([FromBody] CreateCommentWithParametersInput input) public virtual async Task ValidateAsync([FromBody] CreateCommentWithParametersInput input)
{ {
if (CmsKitCommentOptions.IsRecaptchaEnabled && input.CaptchaToken.HasValue) if (CmsKitCommentOptions.IsRecaptchaEnabled && input.CaptchaToken.HasValue)
{ {

4
modules/cms-kit/src/Volo.CmsKit.Public.Web/Controllers/CmsKitPublicGlobalResourcesController.cs

@ -26,7 +26,7 @@ public class CmsKitPublicGlobalResourcesController: AbpController
[HttpGet] [HttpGet]
[Route("style")] [Route("style")]
public async Task<IActionResult> GetGlobalStyleAsync() public virtual async Task<IActionResult> GetGlobalStyleAsync()
{ {
var style = await _resourceCache.GetOrAddAsync( var style = await _resourceCache.GetOrAddAsync(
GlobalResourceConsts.GlobalStyleName, //Cache key GlobalResourceConsts.GlobalStyleName, //Cache key
@ -44,7 +44,7 @@ public class CmsKitPublicGlobalResourcesController: AbpController
[HttpGet] [HttpGet]
[Route("script")] [Route("script")]
public async Task<IActionResult> GetGlobalScriptAsync() public virtual async Task<IActionResult> GetGlobalScriptAsync()
{ {
var script = await _resourceCache.GetOrAddAsync( var script = await _resourceCache.GetOrAddAsync(
GlobalResourceConsts.GlobalScriptName, //Cache key GlobalResourceConsts.GlobalScriptName, //Cache key

14
modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs

@ -47,7 +47,7 @@ namespace Volo.Docs.Admin.Documents
LocalizationResource = typeof(DocsResource); LocalizationResource = typeof(DocsResource);
} }
public async Task ClearCacheAsync(ClearCacheInput input) public virtual async Task ClearCacheAsync(ClearCacheInput input)
{ {
var project = await _projectRepository.GetAsync(input.ProjectId); var project = await _projectRepository.GetAsync(input.ProjectId);
@ -75,7 +75,7 @@ namespace Volo.Docs.Admin.Documents
} }
} }
public async Task PullAllAsync(PullAllDocumentInput input) public virtual async Task PullAllAsync(PullAllDocumentInput input)
{ {
var project = await _projectRepository.GetAsync(input.ProjectId); var project = await _projectRepository.GetAsync(input.ProjectId);
@ -129,7 +129,7 @@ namespace Volo.Docs.Admin.Documents
} }
} }
public async Task PullAsync(PullDocumentInput input) public virtual async Task PullAsync(PullDocumentInput input)
{ {
var project = await _projectRepository.GetAsync(input.ProjectId); var project = await _projectRepository.GetAsync(input.ProjectId);
@ -142,7 +142,7 @@ namespace Volo.Docs.Admin.Documents
await UpdateDocumentUpdateInfoCache(sourceDocument); await UpdateDocumentUpdateInfoCache(sourceDocument);
} }
public async Task<PagedResultDto<DocumentDto>> GetAllAsync(GetAllInput input) public virtual async Task<PagedResultDto<DocumentDto>> GetAllAsync(GetAllInput input)
{ {
var totalCount = await _documentRepository.GetAllCountAsync( var totalCount = await _documentRepository.GetAllCountAsync(
projectId: input.ProjectId, projectId: input.ProjectId,
@ -191,7 +191,7 @@ namespace Volo.Docs.Admin.Documents
}; };
} }
public async Task RemoveFromCacheAsync(Guid documentId) public virtual async Task RemoveFromCacheAsync(Guid documentId)
{ {
var document = await _documentRepository.GetAsync(documentId); var document = await _documentRepository.GetAsync(documentId);
var project = await _projectRepository.GetAsync(document.ProjectId); var project = await _projectRepository.GetAsync(document.ProjectId);
@ -207,7 +207,7 @@ namespace Volo.Docs.Admin.Documents
await _documentRepository.DeleteAsync(document); await _documentRepository.DeleteAsync(document);
} }
public async Task ReindexAsync(Guid documentId) public virtual async Task ReindexAsync(Guid documentId)
{ {
_elasticSearchService.ValidateElasticSearchEnabled(); _elasticSearchService.ValidateElasticSearchEnabled();
@ -216,7 +216,7 @@ namespace Volo.Docs.Admin.Documents
await _elasticSearchService.AddOrUpdateAsync(document); await _elasticSearchService.AddOrUpdateAsync(document);
} }
public async Task<List<DocumentInfoDto>> GetFilterItemsAsync() public virtual async Task<List<DocumentInfoDto>> GetFilterItemsAsync()
{ {
var documents = await _documentRepository.GetUniqueListDocumentInfoAsync(); var documents = await _documentRepository.GetUniqueListDocumentInfoAsync();
return ObjectMapper.Map<List<DocumentInfo>, List<DocumentInfoDto>>(documents); return ObjectMapper.Map<List<DocumentInfo>, List<DocumentInfoDto>>(documents);

16
modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Projects/ProjectAdminAppService.cs

@ -37,7 +37,7 @@ namespace Volo.Docs.Admin.Projects
_guidGenerator = guidGenerator; _guidGenerator = guidGenerator;
} }
public async Task<PagedResultDto<ProjectDto>> GetListAsync(PagedAndSortedResultRequestDto input) public virtual async Task<PagedResultDto<ProjectDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{ {
var projects = await _projectRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount); var projects = await _projectRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount);
@ -49,7 +49,7 @@ namespace Volo.Docs.Admin.Projects
); );
} }
public async Task<ProjectDto> GetAsync(Guid id) public virtual async Task<ProjectDto> GetAsync(Guid id)
{ {
var project = await _projectRepository.GetAsync(id); var project = await _projectRepository.GetAsync(id);
@ -57,7 +57,7 @@ namespace Volo.Docs.Admin.Projects
} }
[Authorize(DocsAdminPermissions.Projects.Create)] [Authorize(DocsAdminPermissions.Projects.Create)]
public async Task<ProjectDto> CreateAsync(CreateProjectDto input) public virtual async Task<ProjectDto> CreateAsync(CreateProjectDto input)
{ {
if (await _projectRepository.ShortNameExistsAsync(input.ShortName)) if (await _projectRepository.ShortNameExistsAsync(input.ShortName))
{ {
@ -90,7 +90,7 @@ namespace Volo.Docs.Admin.Projects
} }
[Authorize(DocsAdminPermissions.Projects.Update)] [Authorize(DocsAdminPermissions.Projects.Update)]
public async Task<ProjectDto> UpdateAsync(Guid id, UpdateProjectDto input) public virtual async Task<ProjectDto> UpdateAsync(Guid id, UpdateProjectDto input)
{ {
var project = await _projectRepository.GetAsync(id); var project = await _projectRepository.GetAsync(id);
@ -115,12 +115,12 @@ namespace Volo.Docs.Admin.Projects
} }
[Authorize(DocsAdminPermissions.Projects.Delete)] [Authorize(DocsAdminPermissions.Projects.Delete)]
public async Task DeleteAsync(Guid id) public virtual async Task DeleteAsync(Guid id)
{ {
await _projectRepository.DeleteAsync(id); await _projectRepository.DeleteAsync(id);
} }
public async Task ReindexAsync(ReindexInput input) public virtual async Task ReindexAsync(ReindexInput input)
{ {
_elasticSearchService.ValidateElasticSearchEnabled(); _elasticSearchService.ValidateElasticSearchEnabled();
@ -146,7 +146,7 @@ namespace Volo.Docs.Admin.Projects
} }
} }
public async Task ReindexAllAsync() public virtual async Task ReindexAllAsync()
{ {
_elasticSearchService.ValidateElasticSearchEnabled(); _elasticSearchService.ValidateElasticSearchEnabled();
var projects = await _projectRepository.GetListAsync(); var projects = await _projectRepository.GetListAsync();
@ -157,7 +157,7 @@ namespace Volo.Docs.Admin.Projects
} }
} }
public async Task<List<ProjectWithoutDetailsDto>> GetListWithoutDetailsAsync() public virtual async Task<List<ProjectWithoutDetailsDto>> GetListWithoutDetailsAsync()
{ {
var projects = await _projectRepository.GetListWithoutDetailsAsync(); var projects = await _projectRepository.GetListWithoutDetailsAsync();
return ObjectMapper.Map<List<ProjectWithoutDetails>, List<ProjectWithoutDetailsDto>>(projects); return ObjectMapper.Map<List<ProjectWithoutDetails>, List<ProjectWithoutDetailsDto>>(projects);

6
modules/docs/src/Volo.Docs.Admin.HttpApi/Volo/Docs/Admin/DocumentsAdminController.cs

@ -52,21 +52,21 @@ namespace Volo.Docs.Admin
[HttpPut] [HttpPut]
[Route("RemoveDocumentFromCache")] [Route("RemoveDocumentFromCache")]
public async Task RemoveFromCacheAsync(Guid documentId) public virtual async Task RemoveFromCacheAsync(Guid documentId)
{ {
await _documentAdminAppService.RemoveFromCacheAsync(documentId); await _documentAdminAppService.RemoveFromCacheAsync(documentId);
} }
[HttpPut] [HttpPut]
[Route("ReindexDocument")] [Route("ReindexDocument")]
public async Task ReindexAsync(Guid documentId) public virtual async Task ReindexAsync(Guid documentId)
{ {
await _documentAdminAppService.ReindexAsync(documentId); await _documentAdminAppService.ReindexAsync(documentId);
} }
[HttpGet] [HttpGet]
[Route("GetFilterItems")] [Route("GetFilterItems")]
public async Task<List<DocumentInfoDto>> GetFilterItemsAsync() public virtual async Task<List<DocumentInfoDto>> GetFilterItemsAsync()
{ {
return await _documentAdminAppService.GetFilterItemsAsync(); return await _documentAdminAppService.GetFilterItemsAsync();
} }

10
modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs

@ -141,7 +141,7 @@ namespace Volo.Docs.Documents
return navigationNode; return navigationNode;
} }
public async Task<DocumentResourceDto> GetResourceAsync(GetDocumentResourceInput input) public virtual async Task<DocumentResourceDto> GetResourceAsync(GetDocumentResourceInput input)
{ {
var project = await _projectRepository.GetAsync(input.ProjectId); var project = await _projectRepository.GetAsync(input.ProjectId);
@ -176,7 +176,7 @@ namespace Volo.Docs.Documents
); );
} }
public async Task<List<DocumentSearchOutput>> SearchAsync(DocumentSearchInput input) public virtual async Task<List<DocumentSearchOutput>> SearchAsync(DocumentSearchInput input)
{ {
var project = await _projectRepository.GetAsync(input.ProjectId); var project = await _projectRepository.GetAsync(input.ProjectId);
@ -197,12 +197,12 @@ namespace Volo.Docs.Documents
.ToList(); .ToList();
} }
public async Task<bool> FullSearchEnabledAsync() public virtual async Task<bool> FullSearchEnabledAsync()
{ {
return await Task.FromResult(_docsElasticSearchOptions.Enable); return await Task.FromResult(_docsElasticSearchOptions.Enable);
} }
public async Task<List<string>> GetUrlsAsync(string prefix) public virtual async Task<List<string>> GetUrlsAsync(string prefix)
{ {
var documentUrls = new List<string>(); var documentUrls = new List<string>();
var projects = await _projectRepository.GetListAsync(); var projects = await _projectRepository.GetListAsync();
@ -321,7 +321,7 @@ namespace Volo.Docs.Documents
path.StartsWith("https://", StringComparison.OrdinalIgnoreCase); path.StartsWith("https://", StringComparison.OrdinalIgnoreCase);
} }
public async Task<DocumentParametersDto> GetParametersAsync(GetParametersDocumentInput input) public virtual async Task<DocumentParametersDto> GetParametersAsync(GetParametersDocumentInput input)
{ {
var project = await _projectRepository.GetAsync(input.ProjectId); var project = await _projectRepository.GetAsync(input.ProjectId);

10
modules/docs/src/Volo.Docs.Application/Volo/Docs/Projects/ProjectAppService.cs

@ -31,7 +31,7 @@ namespace Volo.Docs.Projects
LanguageCache = languageCache; LanguageCache = languageCache;
} }
public async Task<ListResultDto<ProjectDto>> GetListAsync() public virtual async Task<ListResultDto<ProjectDto>> GetListAsync()
{ {
var projects = await _projectRepository.GetListAsync(); var projects = await _projectRepository.GetListAsync();
@ -44,7 +44,7 @@ namespace Volo.Docs.Projects
); );
} }
public async Task<ProjectDto> GetAsync(string shortName) public virtual async Task<ProjectDto> GetAsync(string shortName)
{ {
var project = await _projectRepository.GetByShortNameAsync(shortName); var project = await _projectRepository.GetByShortNameAsync(shortName);
@ -53,7 +53,7 @@ namespace Volo.Docs.Projects
return HidePrivateProperties(projectDto); return HidePrivateProperties(projectDto);
} }
public async Task<ListResultDto<VersionInfoDto>> GetVersionsAsync(string shortName) public virtual async Task<ListResultDto<VersionInfoDto>> GetVersionsAsync(string shortName)
{ {
var project = await _projectRepository.GetByShortNameAsync(shortName); var project = await _projectRepository.GetByShortNameAsync(shortName);
@ -95,12 +95,12 @@ namespace Volo.Docs.Projects
return versions; return versions;
} }
public async Task<LanguageConfig> GetLanguageListAsync(string shortName, string version) public virtual async Task<LanguageConfig> GetLanguageListAsync(string shortName, string version)
{ {
return await GetLanguageListInternalAsync(shortName, version); return await GetLanguageListInternalAsync(shortName, version);
} }
public async Task<string> GetDefaultLanguageCodeAsync(string shortName, string version) public virtual async Task<string> GetDefaultLanguageCodeAsync(string shortName, string version)
{ {
var languageList = await GetLanguageListInternalAsync(shortName, version); var languageList = await GetLanguageListInternalAsync(shortName, version);

18
modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs

@ -18,7 +18,7 @@ namespace Volo.Docs.Documents
{ {
} }
public async Task<List<DocumentWithoutDetails>> GetListWithoutDetailsByProjectId(Guid projectId, CancellationToken cancellationToken = default) public virtual async Task<List<DocumentWithoutDetails>> GetListWithoutDetailsByProjectId(Guid projectId, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.Where(d => d.ProjectId == projectId) .Where(d => d.ProjectId == projectId)
@ -32,7 +32,7 @@ namespace Volo.Docs.Documents
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<DocumentInfo>> GetUniqueListDocumentInfoAsync(CancellationToken cancellationToken = default) public virtual async Task<List<DocumentInfo>> GetUniqueListDocumentInfoAsync(CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
@ -49,13 +49,13 @@ namespace Volo.Docs.Documents
} }
public async Task<List<Document>> GetListByProjectId(Guid projectId, public virtual async Task<List<Document>> GetListByProjectId(Guid projectId,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()).Where(d => d.ProjectId == projectId).ToListAsync(GetCancellationToken(cancellationToken)); return await (await GetDbSetAsync()).Where(d => d.ProjectId == projectId).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<Document>> GetListAsync(Guid? projectId, string version, string name, CancellationToken cancellationToken = default) public virtual async Task<List<Document>> GetListAsync(Guid? projectId, string version, string name, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.WhereIf(version != null, x => x.Version == version) .WhereIf(version != null, x => x.Version == version)
@ -64,7 +64,7 @@ namespace Volo.Docs.Documents
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<DocumentWithoutContent>> GetAllAsync( public virtual async Task<List<DocumentWithoutContent>> GetAllAsync(
Guid? projectId, Guid? projectId,
string name, string name,
string version, string version,
@ -104,7 +104,7 @@ namespace Volo.Docs.Documents
return await query.PageBy(skipCount, maxResultCount).ToListAsync(GetCancellationToken(cancellationToken)); return await query.PageBy(skipCount, maxResultCount).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<long> GetAllCountAsync( public virtual async Task<long> GetAllCountAsync(
Guid? projectId, Guid? projectId,
string name, string name,
string version, string version,
@ -143,7 +143,7 @@ namespace Volo.Docs.Documents
return await query.LongCountAsync(GetCancellationToken(cancellationToken)); return await query.LongCountAsync(GetCancellationToken(cancellationToken));
} }
public async Task<Document> FindAsync(Guid projectId, string name, string languageCode, string version, public virtual async Task<Document> FindAsync(Guid projectId, string name, string languageCode, string version,
bool includeDetails = true, bool includeDetails = true,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
@ -154,14 +154,14 @@ namespace Volo.Docs.Documents
GetCancellationToken(cancellationToken)); GetCancellationToken(cancellationToken));
} }
public async Task DeleteAsync(Guid projectId, string name, string languageCode, string version, bool autoSave = false, CancellationToken cancellationToken = default) public virtual async Task DeleteAsync(Guid projectId, string name, string languageCode, string version, bool autoSave = false, CancellationToken cancellationToken = default)
{ {
await DeleteAsync(x => await DeleteAsync(x =>
x.ProjectId == projectId && x.Name == name && x.LanguageCode == languageCode && x.ProjectId == projectId && x.Name == name && x.LanguageCode == languageCode &&
x.Version == version, autoSave, cancellationToken: cancellationToken); x.Version == version, autoSave, cancellationToken: cancellationToken);
} }
public async Task<Document> GetAsync(Guid id, CancellationToken cancellationToken = default) public virtual async Task<Document> GetAsync(Guid id, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()).Where(x => x.Id == id).SingleAsync(cancellationToken: GetCancellationToken(cancellationToken)); return await (await GetDbSetAsync()).Where(x => x.Id == id).SingleAsync(cancellationToken: GetCancellationToken(cancellationToken));
} }

8
modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Projects/EfCoreProjectRepository.cs

@ -19,7 +19,7 @@ namespace Volo.Docs.Projects
{ {
} }
public async Task<List<Project>> GetListAsync(string sorting, int maxResultCount, int skipCount, CancellationToken cancellationToken = default) public virtual async Task<List<Project>> GetListAsync(string sorting, int maxResultCount, int skipCount, CancellationToken cancellationToken = default)
{ {
var projects = await (await GetDbSetAsync()).OrderBy(sorting.IsNullOrEmpty() ? "Id desc" : sorting) var projects = await (await GetDbSetAsync()).OrderBy(sorting.IsNullOrEmpty() ? "Id desc" : sorting)
.PageBy(skipCount, maxResultCount) .PageBy(skipCount, maxResultCount)
@ -28,7 +28,7 @@ namespace Volo.Docs.Projects
return projects; return projects;
} }
public async Task<List<ProjectWithoutDetails>> GetListWithoutDetailsAsync(CancellationToken cancellationToken = default) public virtual async Task<List<ProjectWithoutDetails>> GetListWithoutDetailsAsync(CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.Select(x=> new ProjectWithoutDetails() { .Select(x=> new ProjectWithoutDetails() {
@ -39,7 +39,7 @@ namespace Volo.Docs.Projects
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<Project> GetByShortNameAsync(string shortName, CancellationToken cancellationToken = default) public virtual async Task<Project> GetByShortNameAsync(string shortName, CancellationToken cancellationToken = default)
{ {
var normalizeShortName = NormalizeShortName(shortName); var normalizeShortName = NormalizeShortName(shortName);
@ -53,7 +53,7 @@ namespace Volo.Docs.Projects
return project; return project;
} }
public async Task<bool> ShortNameExistsAsync(string shortName, CancellationToken cancellationToken = default) public virtual async Task<bool> ShortNameExistsAsync(string shortName, CancellationToken cancellationToken = default)
{ {
var normalizeShortName = NormalizeShortName(shortName); var normalizeShortName = NormalizeShortName(shortName);

18
modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs

@ -20,7 +20,7 @@ namespace Volo.Docs.Documents
{ {
} }
public async Task<List<DocumentWithoutDetails>> GetListWithoutDetailsByProjectId(Guid projectId, CancellationToken cancellationToken = default) public virtual async Task<List<DocumentWithoutDetails>> GetListWithoutDetailsByProjectId(Guid projectId, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.Where(d => d.ProjectId == projectId) .Where(d => d.ProjectId == projectId)
@ -34,7 +34,7 @@ namespace Volo.Docs.Documents
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<DocumentInfo>> GetUniqueListDocumentInfoAsync(CancellationToken cancellationToken = default) public virtual async Task<List<DocumentInfo>> GetUniqueListDocumentInfoAsync(CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.Select(x=> new DocumentInfo { .Select(x=> new DocumentInfo {
@ -48,12 +48,12 @@ namespace Volo.Docs.Documents
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<Document>> GetListByProjectId(Guid projectId, CancellationToken cancellationToken = default) public virtual async Task<List<Document>> GetListByProjectId(Guid projectId, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)).Where(d => d.ProjectId == projectId).ToListAsync(GetCancellationToken(cancellationToken)); return await (await GetMongoQueryableAsync(cancellationToken)).Where(d => d.ProjectId == projectId).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<Document> FindAsync(Guid projectId, string name, string languageCode, string version, public virtual async Task<Document> FindAsync(Guid projectId, string name, string languageCode, string version,
bool includeDetails = true, bool includeDetails = true,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
@ -63,14 +63,14 @@ namespace Volo.Docs.Documents
x.Version == version, GetCancellationToken(cancellationToken)); x.Version == version, GetCancellationToken(cancellationToken));
} }
public async Task DeleteAsync(Guid projectId, string name, string languageCode, string version, bool autoSave = false, CancellationToken cancellationToken = default) public virtual async Task DeleteAsync(Guid projectId, string name, string languageCode, string version, bool autoSave = false, CancellationToken cancellationToken = default)
{ {
await DeleteAsync(x => await DeleteAsync(x =>
x.ProjectId == projectId && x.Name == name && x.LanguageCode == languageCode && x.ProjectId == projectId && x.Name == name && x.LanguageCode == languageCode &&
x.Version == version, autoSave, cancellationToken: cancellationToken); x.Version == version, autoSave, cancellationToken: cancellationToken);
} }
public async Task<List<Document>> GetListAsync(Guid? projectId, string version, string name, CancellationToken cancellationToken = default) public virtual async Task<List<Document>> GetListAsync(Guid? projectId, string version, string name, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.WhereIf(version != null, x => x.Version == version) .WhereIf(version != null, x => x.Version == version)
@ -80,7 +80,7 @@ namespace Volo.Docs.Documents
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<DocumentWithoutContent>> GetAllAsync( public virtual async Task<List<DocumentWithoutContent>> GetAllAsync(
Guid? projectId, Guid? projectId,
string name, string name,
string version, string version,
@ -122,7 +122,7 @@ namespace Volo.Docs.Documents
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<long> GetAllCountAsync( public virtual async Task<long> GetAllCountAsync(
Guid? projectId, Guid? projectId,
string name, string name,
string version, string version,
@ -165,7 +165,7 @@ namespace Volo.Docs.Documents
.LongCountAsync(GetCancellationToken(cancellationToken)); .LongCountAsync(GetCancellationToken(cancellationToken));
} }
public async Task<Document> GetAsync(Guid id, CancellationToken cancellationToken = default) public virtual async Task<Document> GetAsync(Guid id, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.Id == id).SingleAsync(GetCancellationToken(cancellationToken)); return await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.Id == id).SingleAsync(GetCancellationToken(cancellationToken));
} }

8
modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Projects/MongoProjectRepository.cs

@ -20,7 +20,7 @@ namespace Volo.Docs.Projects
{ {
} }
public async Task<List<Project>> GetListAsync(string sorting, int maxResultCount, int skipCount, CancellationToken cancellationToken = default) public virtual async Task<List<Project>> GetListAsync(string sorting, int maxResultCount, int skipCount, CancellationToken cancellationToken = default)
{ {
var projects = await (await GetMongoQueryableAsync(cancellationToken)).OrderBy(sorting.IsNullOrEmpty() ? "Id desc" : sorting).As<IMongoQueryable<Project>>() var projects = await (await GetMongoQueryableAsync(cancellationToken)).OrderBy(sorting.IsNullOrEmpty() ? "Id desc" : sorting).As<IMongoQueryable<Project>>()
.PageBy<Project, IMongoQueryable<Project>>(skipCount, maxResultCount) .PageBy<Project, IMongoQueryable<Project>>(skipCount, maxResultCount)
@ -29,7 +29,7 @@ namespace Volo.Docs.Projects
return projects; return projects;
} }
public async Task<List<ProjectWithoutDetails>> GetListWithoutDetailsAsync(CancellationToken cancellationToken = default) public virtual async Task<List<ProjectWithoutDetails>> GetListWithoutDetailsAsync(CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.Select(x=> new ProjectWithoutDetails { .Select(x=> new ProjectWithoutDetails {
@ -40,7 +40,7 @@ namespace Volo.Docs.Projects
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<Project> GetByShortNameAsync(string shortName, CancellationToken cancellationToken = default) public virtual async Task<Project> GetByShortNameAsync(string shortName, CancellationToken cancellationToken = default)
{ {
var normalizeShortName = NormalizeShortName(shortName); var normalizeShortName = NormalizeShortName(shortName);
@ -54,7 +54,7 @@ namespace Volo.Docs.Projects
return project; return project;
} }
public async Task<bool> ShortNameExistsAsync(string shortName, CancellationToken cancellationToken = default) public virtual async Task<bool> ShortNameExistsAsync(string shortName, CancellationToken cancellationToken = default)
{ {
var normalizeShortName = NormalizeShortName(shortName); var normalizeShortName = NormalizeShortName(shortName);

2
modules/docs/src/Volo.Docs.Web/Areas/Documents/DocumentResourceController.cs

@ -24,7 +24,7 @@ namespace Volo.Docs.Areas.Documents
[HttpGet] [HttpGet]
[Route("")] [Route("")]
public async Task<FileResult> GetResource(GetDocumentResourceInput input) public virtual async Task<FileResult> GetResource(GetDocumentResourceInput input)
{ {
input.Name = input.Name.RemovePreFix("/"); input.Name = input.Name.RemovePreFix("/");
var documentResource = await _documentAppService.GetResourceAsync(input); var documentResource = await _documentAppService.GetResourceAsync(input);

4
modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/EfCoreFeatureValueRepository.cs

@ -28,7 +28,7 @@ public class EfCoreFeatureValueRepository : EfCoreRepository<IFeatureManagementD
.FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey, GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey, GetCancellationToken(cancellationToken));
} }
public async Task<List<FeatureValue>> FindAllAsync( public virtual async Task<List<FeatureValue>> FindAllAsync(
string name, string name,
string providerName, string providerName,
string providerKey, string providerKey,
@ -51,7 +51,7 @@ public class EfCoreFeatureValueRepository : EfCoreRepository<IFeatureManagementD
).ToListAsync(GetCancellationToken(cancellationToken)); ).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task DeleteAsync( public virtual async Task DeleteAsync(
string providerName, string providerName,
string providerKey, string providerKey,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)

2
modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureValueRepository.cs

@ -32,7 +32,7 @@ public class MongoFeatureValueRepository :
.FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey, GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey, GetCancellationToken(cancellationToken));
} }
public async Task<List<FeatureValue>> FindAllAsync( public virtual async Task<List<FeatureValue>> FindAllAsync(
string name, string name,
string providerName, string providerName,
string providerKey, string providerKey,

4
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs

@ -40,7 +40,7 @@ public class IdentityUserLookupAppService : IdentityAppServiceBase, IIdentityUse
return new UserData(userData); return new UserData(userData);
} }
public async Task<ListResultDto<UserData>> SearchAsync(UserLookupSearchInputDto input) public virtual async Task<ListResultDto<UserData>> SearchAsync(UserLookupSearchInputDto input)
{ {
var users = await UserLookupServiceProvider.SearchAsync( var users = await UserLookupServiceProvider.SearchAsync(
input.Sorting, input.Sorting,
@ -56,7 +56,7 @@ public class IdentityUserLookupAppService : IdentityAppServiceBase, IIdentityUse
); );
} }
public async Task<long> GetCountAsync(UserLookupCountInputDto input) public virtual async Task<long> GetCountAsync(UserLookupCountInputDto input)
{ {
return await UserLookupServiceProvider.GetCountAsync(input.Filter); return await UserLookupServiceProvider.GetCountAsync(input.Filter);
} }

6
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserDelegationRepository.cs

@ -20,7 +20,7 @@ public class EfCoreIdentityUserDelegationRepository : EfCoreRepository<IIdentity
Clock = clock; Clock = clock;
} }
public async Task<List<IdentityUserDelegation>> GetListAsync(Guid? sourceUserId, Guid? targetUserId, CancellationToken cancellationToken = default) public virtual async Task<List<IdentityUserDelegation>> GetListAsync(Guid? sourceUserId, Guid? targetUserId, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.AsNoTracking() .AsNoTracking()
@ -29,7 +29,7 @@ public class EfCoreIdentityUserDelegationRepository : EfCoreRepository<IIdentity
.ToListAsync(cancellationToken: cancellationToken); .ToListAsync(cancellationToken: cancellationToken);
} }
public async Task<List<IdentityUserDelegation>> GetActiveDelegationsAsync(Guid targetUserId, CancellationToken cancellationToken = default) public virtual async Task<List<IdentityUserDelegation>> GetActiveDelegationsAsync(Guid targetUserId, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.AsNoTracking() .AsNoTracking()
@ -39,7 +39,7 @@ public class EfCoreIdentityUserDelegationRepository : EfCoreRepository<IIdentity
.ToListAsync(cancellationToken: cancellationToken); .ToListAsync(cancellationToken: cancellationToken);
} }
public async Task<IdentityUserDelegation> FindActiveDelegationByIdAsync(Guid id, CancellationToken cancellationToken = default) public virtual async Task<IdentityUserDelegation> FindActiveDelegationByIdAsync(Guid id, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.AsNoTracking() .AsNoTracking()

6
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserDelegationRepository.cs

@ -21,7 +21,7 @@ public class MongoIdentityUserDelegationRepository : MongoDbRepository<IAbpIdent
Clock = clock; Clock = clock;
} }
public async Task<List<IdentityUserDelegation>> GetListAsync(Guid? sourceUserId, Guid? targetUserId, public virtual async Task<List<IdentityUserDelegation>> GetListAsync(Guid? sourceUserId, Guid? targetUserId,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
@ -31,7 +31,7 @@ public class MongoIdentityUserDelegationRepository : MongoDbRepository<IAbpIdent
.ToListAsync(cancellationToken: cancellationToken); .ToListAsync(cancellationToken: cancellationToken);
} }
public async Task<List<IdentityUserDelegation>> GetActiveDelegationsAsync(Guid targetUserId, CancellationToken cancellationToken = default) public virtual async Task<List<IdentityUserDelegation>> GetActiveDelegationsAsync(Guid targetUserId, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.Where(x => x.TargetUserId == targetUserId) .Where(x => x.TargetUserId == targetUserId)
@ -40,7 +40,7 @@ public class MongoIdentityUserDelegationRepository : MongoDbRepository<IAbpIdent
.ToListAsync(cancellationToken: cancellationToken); .ToListAsync(cancellationToken: cancellationToken);
} }
public async Task<IdentityUserDelegation> FindActiveDelegationByIdAsync(Guid id, CancellationToken cancellationToken = default) public virtual async Task<IdentityUserDelegation> FindActiveDelegationByIdAsync(Guid id, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.FirstOrDefaultAsync(x => .FirstOrDefaultAsync(x =>

6
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs

@ -18,7 +18,7 @@ public class ApiResourceRepository : EfCoreRepository<IIdentityServerDbContext,
} }
public async Task<ApiResource> FindByNameAsync(string apiResourceName, bool includeDetails = true, CancellationToken cancellationToken = default) public virtual async Task<ApiResource> FindByNameAsync(string apiResourceName, bool includeDetails = true, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.IncludeDetails(includeDetails) .IncludeDetails(includeDetails)
@ -26,7 +26,7 @@ public class ApiResourceRepository : EfCoreRepository<IIdentityServerDbContext,
.FirstOrDefaultAsync(apiResource => apiResource.Name == apiResourceName, GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(apiResource => apiResource.Name == apiResourceName, GetCancellationToken(cancellationToken));
} }
public async Task<List<ApiResource>> FindByNameAsync(string[] apiResourceNames, bool includeDetails = true, public virtual async Task<List<ApiResource>> FindByNameAsync(string[] apiResourceNames, bool includeDetails = true,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
@ -64,7 +64,7 @@ public class ApiResourceRepository : EfCoreRepository<IIdentityServerDbContext,
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default) public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(), .WhereIf(!filter.IsNullOrWhiteSpace(),

10
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiScopes/ApiScopeRepository.cs

@ -18,7 +18,7 @@ public class ApiScopeRepository : EfCoreRepository<IIdentityServerDbContext, Api
{ {
} }
public async Task<ApiScope> FindByNameAsync(string scopeName, bool includeDetails = true, CancellationToken cancellationToken = default) public virtual async Task<ApiScope> FindByNameAsync(string scopeName, bool includeDetails = true, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.IncludeDetails(includeDetails) .IncludeDetails(includeDetails)
@ -26,7 +26,7 @@ public class ApiScopeRepository : EfCoreRepository<IIdentityServerDbContext, Api
.FirstOrDefaultAsync(x => x.Name == scopeName, GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(x => x.Name == scopeName, GetCancellationToken(cancellationToken));
} }
public async Task<List<ApiScope>> GetListByNameAsync(string[] scopeNames, bool includeDetails = false, public virtual async Task<List<ApiScope>> GetListByNameAsync(string[] scopeNames, bool includeDetails = false,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
@ -36,7 +36,7 @@ public class ApiScopeRepository : EfCoreRepository<IIdentityServerDbContext, Api
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<ApiScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null, bool includeDetails = false, CancellationToken cancellationToken = default) public virtual async Task<List<ApiScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null, bool includeDetails = false, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.IncludeDetails(includeDetails) .IncludeDetails(includeDetails)
@ -48,7 +48,7 @@ public class ApiScopeRepository : EfCoreRepository<IIdentityServerDbContext, Api
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default) public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(), .WhereIf(!filter.IsNullOrWhiteSpace(),
@ -58,7 +58,7 @@ public class ApiScopeRepository : EfCoreRepository<IIdentityServerDbContext, Api
.LongCountAsync(GetCancellationToken(cancellationToken)); .LongCountAsync(GetCancellationToken(cancellationToken));
} }
public async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default) public virtual async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()).AnyAsync(x => x.Id != expectedId && x.Name == name, GetCancellationToken(cancellationToken)); return await (await GetDbSetAsync()).AnyAsync(x => x.Id != expectedId && x.Name == name, GetCancellationToken(cancellationToken));
} }

2
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Clients/ClientRepository.cs

@ -41,7 +41,7 @@ public class ClientRepository : EfCoreRepository<IIdentityServerDbContext, Clien
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default) public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter)) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter))

4
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Grants/PersistentGrantRepository.cs

@ -18,7 +18,7 @@ public class PersistentGrantRepository : EfCoreRepository<IIdentityServerDbConte
} }
public async Task<List<PersistedGrant>> GetListAsync(string subjectId, string sessionId, string clientId, string type, bool includeDetails = false, public virtual async Task<List<PersistedGrant>> GetListAsync(string subjectId, string sessionId, string clientId, string type, bool includeDetails = false,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await FilterAsync(subjectId, sessionId, clientId, type)) return await (await FilterAsync(subjectId, sessionId, clientId, type))
@ -60,7 +60,7 @@ public class PersistentGrantRepository : EfCoreRepository<IIdentityServerDbConte
await DeleteDirectAsync(x => x.Expiration != null && x.Expiration < maxExpirationDate, cancellationToken); await DeleteDirectAsync(x => x.Expiration != null && x.Expiration < maxExpirationDate, cancellationToken);
} }
public async Task DeleteAsync( public virtual async Task DeleteAsync(
string subjectId = null, string subjectId = null,
string sessionId = null, string sessionId = null,
string clientId = null, string clientId = null,

2
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceRepository.cs

@ -54,7 +54,7 @@ public class IdentityResourceRepository : EfCoreRepository<IIdentityServerDbCont
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default) public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(), .WhereIf(!filter.IsNullOrWhiteSpace(),

6
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiResourceRepository.cs

@ -18,14 +18,14 @@ public class MongoApiResourceRepository : MongoDbRepository<IAbpIdentityServerMo
{ {
} }
public async Task<ApiResource> FindByNameAsync(string apiResourceName, bool includeDetails = true, CancellationToken cancellationToken = default) public virtual async Task<ApiResource> FindByNameAsync(string apiResourceName, bool includeDetails = true, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.OrderBy(ar => ar.Id) .OrderBy(ar => ar.Id)
.FirstOrDefaultAsync(ar => ar.Name == apiResourceName, GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(ar => ar.Name == apiResourceName, GetCancellationToken(cancellationToken));
} }
public async Task<List<ApiResource>> FindByNameAsync(string[] apiResourceNames, bool includeDetails = true, public virtual async Task<List<ApiResource>> FindByNameAsync(string[] apiResourceNames, bool includeDetails = true,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
@ -55,7 +55,7 @@ public class MongoApiResourceRepository : MongoDbRepository<IAbpIdentityServerMo
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default) public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.WhereIf<ApiResource, IMongoQueryable<ApiResource>>(!filter.IsNullOrWhiteSpace(), .WhereIf<ApiResource, IMongoQueryable<ApiResource>>(!filter.IsNullOrWhiteSpace(),

10
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiScopeRepository.cs

@ -20,14 +20,14 @@ public class MongoApiScopeRepository : MongoDbRepository<IAbpIdentityServerMongo
{ {
} }
public async Task<ApiScope> FindByNameAsync(string scopeName, bool includeDetails = true, CancellationToken cancellationToken = default) public virtual async Task<ApiScope> FindByNameAsync(string scopeName, bool includeDetails = true, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.OrderBy(x => x.Id) .OrderBy(x => x.Id)
.FirstOrDefaultAsync(x => x.Name == scopeName, GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(x => x.Name == scopeName, GetCancellationToken(cancellationToken));
} }
public async Task<List<ApiScope>> GetListByNameAsync(string[] scopeNames, bool includeDetails = false, public virtual async Task<List<ApiScope>> GetListByNameAsync(string[] scopeNames, bool includeDetails = false,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
@ -36,7 +36,7 @@ public class MongoApiScopeRepository : MongoDbRepository<IAbpIdentityServerMongo
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<ApiScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null, bool includeDetails = false, public virtual async Task<List<ApiScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null, bool includeDetails = false,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
@ -50,7 +50,7 @@ public class MongoApiScopeRepository : MongoDbRepository<IAbpIdentityServerMongo
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default) public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.WhereIf<ApiScope, IMongoQueryable<ApiScope>>(!filter.IsNullOrWhiteSpace(), .WhereIf<ApiScope, IMongoQueryable<ApiScope>>(!filter.IsNullOrWhiteSpace(),
@ -60,7 +60,7 @@ public class MongoApiScopeRepository : MongoDbRepository<IAbpIdentityServerMongo
.LongCountAsync(GetCancellationToken(cancellationToken)); .LongCountAsync(GetCancellationToken(cancellationToken));
} }
public async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default) public virtual async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.AnyAsync(x => x.Id != expectedId && x.Name == name, GetCancellationToken(cancellationToken)); .AnyAsync(x => x.Id != expectedId && x.Name == name, GetCancellationToken(cancellationToken));

2
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoClientRepository.cs

@ -47,7 +47,7 @@ public class MongoClientRepository : MongoDbRepository<IAbpIdentityServerMongoDb
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default) public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.WhereIf<Client, IMongoQueryable<Client>>(!filter.IsNullOrWhiteSpace(), .WhereIf<Client, IMongoQueryable<Client>>(!filter.IsNullOrWhiteSpace(),

2
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoIdentityResourceRepository.cs

@ -30,7 +30,7 @@ public class MongoIdentityResourceRepository : MongoDbRepository<IAbpIdentitySer
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default) public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.WhereIf<IdentityResource, IMongoQueryable<IdentityResource>>(!filter.IsNullOrWhiteSpace(), .WhereIf<IdentityResource, IMongoQueryable<IdentityResource>>(!filter.IsNullOrWhiteSpace(),

4
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoPersistentGrantRepository.cs

@ -18,7 +18,7 @@ public class MongoPersistentGrantRepository : MongoDbRepository<IAbpIdentityServ
{ {
} }
public async Task<List<PersistedGrant>> GetListAsync(string subjectId, string sessionId, string clientId, string type, bool includeDetails = false, public virtual async Task<List<PersistedGrant>> GetListAsync(string subjectId, string sessionId, string clientId, string type, bool includeDetails = false,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await FilterAsync(subjectId, sessionId, clientId, type, cancellationToken)) return await (await FilterAsync(subjectId, sessionId, clientId, type, cancellationToken))
@ -55,7 +55,7 @@ public class MongoPersistentGrantRepository : MongoDbRepository<IAbpIdentityServ
await DeleteDirectAsync(x => x.Expiration != null && x.Expiration < maxExpirationDate, cancellationToken: cancellationToken); await DeleteDirectAsync(x => x.Expiration != null && x.Expiration < maxExpirationDate, cancellationToken: cancellationToken);
} }
public async Task DeleteAsync( public virtual async Task DeleteAsync(
string subjectId = null, string subjectId = null,
string sessionId = null, string sessionId = null,
string clientId = null, string clientId = null,

4
modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Applications/EfCoreOpenIddictApplicationRepository.cs

@ -19,7 +19,7 @@ public class EfCoreOpenIddictApplicationRepository : EfCoreRepository<IOpenIddic
} }
public async Task<List<OpenIddictApplication>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null, public virtual async Task<List<OpenIddictApplication>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
@ -29,7 +29,7 @@ public class EfCoreOpenIddictApplicationRepository : EfCoreRepository<IOpenIddic
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default) public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter)) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter))

4
modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Scopes/EfCoreOpenIddictScopeRepository.cs

@ -19,7 +19,7 @@ public class EfCoreOpenIddictScopeRepository : EfCoreRepository<IOpenIddictDbCon
} }
public async Task<List<OpenIddictScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null, public virtual async Task<List<OpenIddictScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
@ -32,7 +32,7 @@ public class EfCoreOpenIddictScopeRepository : EfCoreRepository<IOpenIddictDbCon
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default) public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(), x => .WhereIf(!filter.IsNullOrWhiteSpace(), x =>

14
modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Applications/MongoOpenIddictApplicationRepository.cs

@ -18,7 +18,7 @@ public class MongoOpenIddictApplicationRepository : MongoDbRepository<OpenIddict
{ {
} }
public async Task<List<OpenIddictApplication>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null, public virtual async Task<List<OpenIddictApplication>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await ((await GetMongoQueryableAsync(cancellationToken))) return await ((await GetMongoQueryableAsync(cancellationToken)))
@ -29,7 +29,7 @@ public class MongoOpenIddictApplicationRepository : MongoDbRepository<OpenIddict
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default) public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{ {
return await ((await GetMongoQueryableAsync(cancellationToken))) return await ((await GetMongoQueryableAsync(cancellationToken)))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter)) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter))
@ -37,28 +37,28 @@ public class MongoOpenIddictApplicationRepository : MongoDbRepository<OpenIddict
.LongCountAsync(GetCancellationToken(cancellationToken)); .LongCountAsync(GetCancellationToken(cancellationToken));
} }
public async Task<OpenIddictApplication> FindByClientIdAsync(string clientId, CancellationToken cancellationToken = default) public virtual async Task<OpenIddictApplication> FindByClientIdAsync(string clientId, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.FirstOrDefaultAsync(x => x.ClientId == clientId, cancellationToken); .FirstOrDefaultAsync(x => x.ClientId == clientId, cancellationToken);
} }
public async Task<List<OpenIddictApplication>> FindByPostLogoutRedirectUriAsync(string address, CancellationToken cancellationToken = default) public virtual async Task<List<OpenIddictApplication>> FindByPostLogoutRedirectUriAsync(string address, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.PostLogoutRedirectUris.Contains(address)).ToListAsync(GetCancellationToken(cancellationToken)); return await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.PostLogoutRedirectUris.Contains(address)).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<OpenIddictApplication>> FindByRedirectUriAsync(string address, CancellationToken cancellationToken = default) public virtual async Task<List<OpenIddictApplication>> FindByRedirectUriAsync(string address, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.RedirectUris.Contains(address)).ToListAsync(GetCancellationToken(cancellationToken)); return await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.RedirectUris.Contains(address)).ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<TResult> GetAsync<TState, TResult>(Func<IQueryable<OpenIddictApplication>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken = default) public virtual async Task<TResult> GetAsync<TState, TResult>(Func<IQueryable<OpenIddictApplication>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken = default)
{ {
return await query(await GetMongoQueryableAsync(cancellationToken), state).As<IMongoQueryable<TResult>>().FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); return await query(await GetMongoQueryableAsync(cancellationToken), state).As<IMongoQueryable<TResult>>().FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
} }
public async Task<List<OpenIddictApplication>> ListAsync(int? count, int? offset, CancellationToken cancellationToken = default) public virtual async Task<List<OpenIddictApplication>> ListAsync(int? count, int? offset, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.OrderBy(x => x.Id) .OrderBy(x => x.Id)

4
modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Scopes/MongoOpenIddictScopeRepository.cs

@ -18,7 +18,7 @@ public class MongoOpenIddictScopeRepository : MongoDbRepository<OpenIddictMongoD
{ {
} }
public async Task<List<OpenIddictScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null, public virtual async Task<List<OpenIddictScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
@ -32,7 +32,7 @@ public class MongoOpenIddictScopeRepository : MongoDbRepository<OpenIddictMongoD
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default) public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => .WhereIf(!filter.IsNullOrWhiteSpace(), x =>

2
modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo/Abp/PermissionManagement/EntityFrameworkCore/EfCorePermissionDefinitionRecordRepository.cs

@ -18,7 +18,7 @@ public class EfCorePermissionDefinitionRecordRepository :
{ {
} }
public async Task<PermissionDefinitionRecord> FindByNameAsync( public virtual async Task<PermissionDefinitionRecord> FindByNameAsync(
string name, string name,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {

2
modules/permission-management/src/Volo.Abp.PermissionManagement.MongoDB/Volo/Abp/PermissionManagement/MongoDb/MongoPermissionDefinitionRecordRepository.cs

@ -17,7 +17,7 @@ public class MongoPermissionDefinitionRecordRepository :
{ {
} }
public async Task<PermissionDefinitionRecord> FindByNameAsync( public virtual async Task<PermissionDefinitionRecord> FindByNameAsync(
string name, string name,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {

Loading…
Cancel
Save