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)
-
0
Hi,
The
CurrentUser
contains the TenantId.You can get the tenant information via
ITenantRepository
. Thetenant
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; } }
-
0
This question has been automatically marked as stale because it has not had recent activity.