Starts in:
0 DAY
20 HRS
45 MIN
23 SEC
Starts in:
0 D
20 H
45 M
23 S
Open Closed

How to get Saas edition for current logged-in user? #1510


User avatar
0
DJudge created

Hi,

We are using MVC 4.3.2 with Angular, how do we get access to edition id and edition name for the current logged-in user?


2 Answer(s)
  • User Avatar
    0
    cotur created

    Hi,

    The CurrentUser contains the TenantId.

    You can get the tenant information via ITenantRepository. The tenant entity contains it's edition id.

    // DI
    private readonly ICurrentUser _currentUser;
    private readonly ITenantRepository _tenantRepository;
    private readonly IEditionRepository _editionRepository;
    
    ctor(ICurrentUser currentUser, ITenantRepository tenantRepository, IEditionRepository editionRepository){
        _currentUser = currentUser;
        _tenantRepository = tenantRepository;
        _editionRepository = editionRepository;
    }
    
    public async Task<Guid?> GetEditionId(){
    
                var tenantId = CurrentUser.TenantId;
    
                if (!tenantId.HasValue)
                {
                    return null;
                }
                else
                {
                    var tenant = await _tenantRepository.GetAsync(tenantId.Value);
    
                    if (!tenant.EditionId.HasValue)
                    {
                        return null;
                    }
    
                    var edition = await _editionRepository.GetAsync(tenant.EditionId.Value);
                    
                    return edition.Id;
                }
    }
    
  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06