First Commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using ADS.Helpers.MultiTenant.Abstractions;
|
||||
using ADS.Helpers.MultiTenant.Context;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace ADS.Helpers.MultiTenant.Stores;
|
||||
|
||||
public sealed class ConfigurationTenantStore : ITenantStore
|
||||
{
|
||||
private readonly IConfiguration _cfg;
|
||||
|
||||
public ConfigurationTenantStore(IConfiguration cfg) => _cfg = cfg;
|
||||
|
||||
public Task<TenantContext?> GetAsync(string tenantKey)
|
||||
{
|
||||
var section = _cfg.GetSection($"Tenants:{tenantKey}");
|
||||
if (!section.Exists()) return Task.FromResult<TenantContext?>(null);
|
||||
|
||||
var tenant = section.Get<TenantContext>() ?? new TenantContext();
|
||||
tenant.TenantId = tenantKey; // importante
|
||||
return Task.FromResult<TenantContext?>(tenant);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user