diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/Organizations/IOrganizationUnitRepository.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/Organizations/IOrganizationUnitRepository.cs index fad8b044f8..81bd90acea 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/Organizations/IOrganizationUnitRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/Organizations/IOrganizationUnitRepository.cs @@ -18,8 +18,5 @@ namespace Volo.Abp.Identity.Organizations Task GetOrganizationUnit(string displayName, bool includeDetails = false, CancellationToken cancellationToken = default); - Task AddRole(OrganizationUnit ou, IdentityRole role, Guid? tenantId, CancellationToken cancellationToken = default); - - Task RemoveRole(OrganizationUnit ou, IdentityRole role, Guid? tenantId, CancellationToken cancellationToken = default); } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/Organizations/OrganizationUnitManager.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/Organizations/OrganizationUnitManager.cs index 356201aef9..9ed2a54697 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/Organizations/OrganizationUnitManager.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/Organizations/OrganizationUnitManager.cs @@ -156,16 +156,16 @@ namespace Volo.Abp.Identity.Organizations ); } - public virtual async Task AddRoleToOrganizationUnitAsync(IdentityRole role, OrganizationUnit ou) + public virtual Task AddRoleToOrganizationUnitAsync(IdentityRole role, OrganizationUnit ou) { var currentRoles = ou.Roles; if (currentRoles.Any(r => r.Id == role.Id)) { - return ; + return Task.FromResult(0); } ou.AddRole(role.Id); - await _organizationUnitRepository.AddRole(ou, role, ou.TenantId); + return Task.FromResult(0); } public virtual async Task RemoveRoleFromOrganizationUnitAsync(Guid roleId, Guid ouId) @@ -176,10 +176,10 @@ namespace Volo.Abp.Identity.Organizations ); } - public virtual async Task RemoveRoleFromOrganizationUnitAsync(IdentityRole role, OrganizationUnit organizationUnit) + public virtual Task RemoveRoleFromOrganizationUnitAsync(IdentityRole role, OrganizationUnit organizationUnit) { - await _organizationUnitRepository.RemoveRole(organizationUnit, role, organizationUnit.TenantId); organizationUnit.RemoveRole(role.Id); + return Task.FromResult(0); } } } diff --git a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs index 2519efc617..7d4a8a1fa0 100644 --- a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs @@ -52,24 +52,6 @@ namespace Volo.Abp.Identity.EntityFrameworkCore ).ConfigureAwait(false); } - public Task AddRole(OrganizationUnit ou, IdentityRole role, Guid? tenantId, CancellationToken cancellationToken = default) - { - var our = new OrganizationUnitRole(tenantId, role.Id, ou.Id); - DbContext.Set().Add(our); - return Task.FromResult(0); - } - - public async Task RemoveRole(OrganizationUnit ou, IdentityRole role, Guid? tenantId, CancellationToken cancellationToken = default) - { - var context = DbContext.Set(); - var our = await context.FirstOrDefaultAsync(our => - our.OrganizationUnitId == ou.Id && - our.RoleId == role.Id && - our.TenantId == tenantId - ); - DbContext.Set().Remove(our); - } - public override IQueryable WithDetails() { return GetQueryable().IncludeDetails(); diff --git a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs index 8e904b2c5b..483daf31a7 100644 --- a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs @@ -52,15 +52,5 @@ namespace Volo.Abp.Identity.MongoDB GetCancellationToken(cancellationToken) ).ConfigureAwait(false); } - - public Task AddRole(OrganizationUnit ou, IdentityRole role, Guid? tenantId, CancellationToken cancellationToken = default) - { - throw new NotImplementedException(); - } - - public Task RemoveRole(OrganizationUnit ou, IdentityRole role, Guid? tenantId, CancellationToken cancellationToken = default) - { - throw new NotImplementedException(); - } } } diff --git a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/Identity_Repository_Resolve_Tests.cs b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/Identity_Repository_Resolve_Tests.cs index 480e72f4cc..0b8821d363 100644 --- a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/Identity_Repository_Resolve_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/Identity_Repository_Resolve_Tests.cs @@ -22,8 +22,6 @@ namespace Volo.Abp.Identity ServiceProvider.GetService>().ShouldNotBeNull(); ServiceProvider.GetService().ShouldNotBeNull(); - ServiceProvider.GetService>().ShouldNotBeNull(); - ServiceProvider.GetService>().ShouldNotBeNull(); ServiceProvider.GetService().ShouldNotBeNull(); } }