29 lines
811 B
C#
29 lines
811 B
C#
using Microsoft.AspNetCore.Http;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
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];
|
|
}
|
|
}
|