private async Task <bool> SetupCloudscribeCore(HttpResponse response) { bool result = true; if (!schemaHasBeenCreated) { if (canAlterSchema) { schemaHasBeenCreated = await CreateInitialSchema(response, "cloudscribe-core"); if (schemaHasBeenCreated) { //recheck needCoreSchemaUpgrade = setupManager.NeedsUpgrade("cloudscribe-core"); } } } if ( (schemaHasBeenCreated) && (needCoreSchemaUpgrade) && (canAlterSchema) ) { needCoreSchemaUpgrade = await UpgradeSchema(response, "cloudscribe-core"); } if (!CoreSystemIsReady()) { return(false); } existingSiteCount = await siteManager.ExistingSiteCount(); if (existingSiteCount == 0) { await WritePageContent(response, "CreatingSite" //SetupResources.CreatingSiteMessage , true); SiteSettings newSite = await siteManager.CreateNewSite(true); await WritePageContent(response, "CreatingRolesAndAdminUser" //SetupResources.CreatingRolesAndAdminUserMessage , true); result = await siteManager.CreateRequiredRolesAndAdminUser(newSite); } else { // check here if count of users is 0 // if something went wrong with creating admin user // setup page should try to correct it on subsequent runs // ie create an admin user if no users exist if (response.HttpContext.Request.Host.HasValue) { ISiteSettings site = await siteManager.Fetch(response.HttpContext.Request.Host.Value); if (site != null) { int roleCount = await siteManager.GetRoleCount(site.SiteId); bool roleResult = true; if (roleCount == 0) { roleResult = await siteManager.EnsureRequiredRoles(site); } if (roleResult) { int userCount = await siteManager.GetUserCount(site.SiteId); if (userCount == 0) { await siteManager.CreateAdminUser(site); } } } } } //TODO dbSiteSettingsEx.EnsureSettings(); add to ISiteRepository return(result); }