using Microsoft.AspNetCore.Http; using APT.Infrastructure.Api; namespace APT.Infrastructure.EF { public class SimpleHeaderTenantInfoGenerator : ITenantInfoGenerator { private readonly TenantInfo tenantInfo; public SimpleHeaderTenantInfoGenerator(TenantInfo tenantInfo) { this.tenantInfo = tenantInfo; } public TenantInfo GenerateTenant(object sender, Microsoft.AspNetCore.Http.HttpContext httpContext) { if (!this.tenantInfo.IsPresent) { var tenantName = httpContext?.Request?.Headers["TenantName"]; if (!string.IsNullOrEmpty(tenantName)) { this.tenantInfo.IsPresent = true; this.tenantInfo.Name = tenantName; this.tenantInfo.Generator = this; } } return this.tenantInfo; } } }