public Task Invoke(HttpContext httpContext, ApothecaricDbContext dbContext) { string urlHost = httpContext.Request.Host.ToString(); if (string.IsNullOrEmpty(urlHost)) { throw new ApplicationException("urlHost must be specified"); } urlHost = urlHost.Remove(urlHost.IndexOf(":"), urlHost.Length - urlHost.IndexOf(":")).ToLower().Trim(); Tenant tenant = dbContext.Tenants.FirstOrDefault(a => a.DomainName.ToLower() == urlHost); if (tenant == null) { tenant = dbContext.Tenants.FirstOrDefault(a => a.IsDefault); if (tenant == null) { throw new ApplicationException("tenant not found based on URL, no default found"); } } httpContext.Items.Add("TENANT", tenant); return(next(httpContext)); }
public AccountController(IConfiguration configuration, ApothecaricUserManager userManager, SignInManager <ApothecaricUser> signinManager, ApothecaricDbContext context) { this.configuration = configuration; this.userManager = userManager; this.signinManager = signinManager; this.dbContext = context; }