Ejemplo n.º 1
0
 public ApplicationDbContext(DbContextOptions <ApplicationDbContext> options,
                             IConfiguration configuration,
                             ITenantProvider tenantProvider)
     : base(options)
 {
     _configuration = configuration;
     _tenant        = tenantProvider.GetCurrentTenant();
 }
 public async Task InvokeAsync(HttpContext context, ITenantProvider tenantProvider)
 {
     if (tenantProvider.GetCurrentTenant() == null)
     {
         context.Response.Redirect(_missingTenantUrl);
     }
     await _next(context);
 }
Ejemplo n.º 3
0
        public async Task InvokeAsync(HttpContext context, ITenantProvider tenantProvider,
                                      ICurrentTenantContextAccessor tenantContextAccessor)
        {
            var tenant = await tenantProvider.GetCurrentTenant();

            try
            {
                tenantContextAccessor.TenantContext = new TenantContext {
                    Tenant = tenant
                };
                await _next(context);
            }
            finally
            {
                tenantContextAccessor.TenantContext = null;
            }
        }
 public EMSAppDbContext(DbContextOptions <EMSAppDbContext> options, ITenantProvider tenantProvider) : base(options)
 {
     _tenant = tenantProvider.GetCurrentTenant().Result;
 }
 public Tenant Get()
 {
     return(_tenantProvider.GetCurrentTenant());
 }