using Microsoft.AspNetCore.Http;
#nullable disable
namespace Marco.Pms.Model.Providers
{
    public sealed class TenantProvider
    {
        // https://www.milanjovanovic.tech/blog/multi-tenant-applications-with-ef-core
        //https://www.youtube.com/watch?v=Gf1sCvikpgI
        private const string TenantIdHeaderName = "X-TenantId";

        private readonly IHttpContextAccessor _httpContextAccessor;

        public TenantProvider(IHttpContextAccessor httpContextAccessor)
        {
            _httpContextAccessor = httpContextAccessor;
        }

        public string TenantId => _httpContextAccessor
            .HttpContext
            .Request
            .Headers[TenantIdHeaderName];
    }
}
