Hi, I trying multitenancy in Blazor server app and I want show Tenant Name in Main layout. Trying to use Globals.Tenant.Name produce error because Globals.Tenant is null using a tenant user.
Can you give directions to solve this problem?
Thanks in advance.
enchev
November 6, 2022, 9:07am
2
Carlos_Carminati:
Globals.Tenant
This is something used in development only. In production when a user is logged you can get the tenant from the user.
Thanks.
It's working with ${Security.User.ApplicationTenant?.Name}
Cheers.
In development await Security.GetUsers()
return null because globals.Tenant is null.
Any workaround? I need to populate a dropdown with list of username of current tenant.
Thanks.
Solved extending SecurityService class with:
public async Task<IEnumerable<ApplicationUser>> GetUsersByTenantId(int tenantId)
{
return await Task.FromResult(context.Users.AsNoTracking().AsQueryable().Where(i => i.TenantId == tenantId).Include(i => i.ApplicationTenant));
}
Thanks