File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
application/account-management/Core/Features/Tenants/Domain Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 11using Microsoft . EntityFrameworkCore ;
22using PlatformPlatform . AccountManagement . Database ;
33using PlatformPlatform . SharedKernel . Domain ;
4+ using PlatformPlatform . SharedKernel . ExecutionContext ;
45using PlatformPlatform . SharedKernel . Persistence ;
56
67namespace PlatformPlatform . AccountManagement . Features . Tenants . Domain ;
78
89public interface ITenantRepository : ICrudRepository < Tenant , TenantId >
910{
11+ Task < Tenant > GetCurrentTenantAsync ( CancellationToken cancellationToken ) ;
12+
1013 Task < bool > ExistsAsync ( TenantId id , CancellationToken cancellationToken ) ;
1114
1215 Task < bool > IsSubdomainFreeAsync ( string subdomain , CancellationToken cancellationToken ) ;
1316}
1417
15- internal sealed class TenantRepository ( AccountManagementDbContext accountManagementDbContext )
18+ internal sealed class TenantRepository ( AccountManagementDbContext accountManagementDbContext , IExecutionContext executionContext )
1619 : RepositoryBase < Tenant , TenantId > ( accountManagementDbContext ) , ITenantRepository
1720{
21+ public async Task < Tenant > GetCurrentTenantAsync ( CancellationToken cancellationToken )
22+ {
23+ ArgumentNullException . ThrowIfNull ( executionContext . TenantId ! ) ;
24+ return await GetByIdAsync ( executionContext . TenantId , cancellationToken ) ??
25+ throw new InvalidOperationException ( "Active tenant not found." ) ;
26+ }
27+
1828 public Task < bool > IsSubdomainFreeAsync ( string subdomain , CancellationToken cancellationToken )
1929 {
2030 return DbSet . AllAsync ( tenant => tenant . Id != subdomain , cancellationToken ) ;
You can’t perform that action at this time.
0 commit comments