Table of Contents

Class TenantModuleService

Namespace
KadicAuth.Infrastructure.Services
Assembly
KadicAuth.Infrastructure.dll

IMemoryCache-backed implementation of KadicErp.Core.Abstractions.Tenancy.ITenantModuleService. Caches the full active-module-key set per tenant for 5 minutes, with a per-tenant lock to avoid thundering-herd on first read.

public sealed class TenantModuleService : ITenantModuleService
Inheritance
object
TenantModuleService
Implements
ITenantModuleService

Constructors

TenantModuleService(ITenantModuleRepository, IMemoryCache)

public TenantModuleService(ITenantModuleRepository repository, IMemoryCache cache)

Parameters

repository ITenantModuleRepository
cache IMemoryCache

Methods

GetActiveModuleKeysAsync(Guid, CancellationToken)

Returns the set of active module keys for the tenant. Useful for UI that needs to render the module list, and for batch checks.

public Task<IReadOnlyCollection<string>> GetActiveModuleKeysAsync(Guid tenantId, CancellationToken cancellationToken = default)

Parameters

tenantId Guid
cancellationToken CancellationToken

Returns

Task<IReadOnlyCollection<string>>

InvalidateCache(Guid)

Invalidate the cached entry for a tenant after admin changes (assign/unassign/activate/deactivate of TenantModule).

public void InvalidateCache(Guid tenantId)

Parameters

tenantId Guid

IsModuleActiveAsync(Guid, string, CancellationToken)

Returns true iff TenantModule exists, IsActive=true, AND the underlying Module (matched by ModuleKey, case-sensitive) is itself IsActive=true.

public Task<bool> IsModuleActiveAsync(Guid tenantId, string moduleKey, CancellationToken cancellationToken = default)

Parameters

tenantId Guid
moduleKey string
cancellationToken CancellationToken

Returns

Task<bool>