// what about localhost or default site address .. saas index page?? public void SetTenantStatus(SAASType sAASType) { if (!sAASType.Equals(SAASType.NoSaas)) { RFDB db = new RFDB(); string siteURL = new Http().HttpContext.Request.Host.Value.Split('.')[0]; if (!string.IsNullOrEmpty(siteURL)) // why i need this at least i will get localhost { Tenant tenant = new Tenant(); var cookieTenant = cookieManager.Get("_tenant"); if (!string.IsNullOrEmpty(cookieTenant)) { tenant.SubdomainPrefix = cookieTenant; } else { tenant = db.Get <Tenant>(exp => exp.SubdomainPrefix == siteURL, new SaasRoutingContext()).FirstOrDefault(); } if (tenant != null) { cookieManager.Set("_tenant", tenant.SubdomainPrefix); CurrentTenant = tenant.SubdomainPrefix; if (tenant.IsPendingUpdate) { db.ExecuteSQLFile(tenant.UpdateSQL, this, siteURL); } } } } }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { IConfigurationRoot configuration = new ConfigurationBuilder() .SetBasePath(AppDomain.CurrentDomain.BaseDirectory) .AddJsonFile("appsettings.json") .Build(); string conStr = configuration.GetConnectionString(connectionStirng); if (sAASType.Equals(SAASType.Database)) { optionsBuilder.UseSqlServer(TenantString(conStr, CurrentTenant)).ReplaceService <IModelCacheKeyFactory, SassModelCacheKeyFactory>(); } else { optionsBuilder.UseSqlServer(conStr).ReplaceService <IModelCacheKeyFactory, SassModelCacheKeyFactory>(); } }