public async Task SetTheme(SetThemeInput input) { var theme = await _themeManager.GetTheme(input.ThemeId, _server); await _settingStore.UpdateAsync(Settings.ThemeInitialConfig(TenantId, theme.ThemeUniqueName)); var themeFromFile = await _themeManager.GetThemeByThemeName(input.ThemeId, HttpContext.Current.Server); _pymeManager.SetMainPageContent(themeFromFile, input.KeepOldData); }
public async Task CreateTenant(CreateTenantInput input) { //Create tenant var tenant = input.MapTo <Tenant>(); tenant.ConnectionString = input.ConnectionString.IsNullOrEmpty() ? null : SimpleStringCipher.Instance.Encrypt(input.ConnectionString); var defaultEdition = await _editionManager.FindByNameAsync(EditionManager.DefaultEditionName); if (defaultEdition != null) { tenant.EditionId = defaultEdition.Id; } CheckErrors(await TenantManager.CreateAsync(tenant)); await CurrentUnitOfWork.SaveChangesAsync(); //To get new tenant's id. //Create tenant database _abpZeroDbMigrator.CreateOrMigrateForTenant(tenant); //We are working entities of new tenant, so changing tenant filter using (CurrentUnitOfWork.SetTenantId(tenant.Id)) { //Create static roles for new tenant CheckErrors(await _roleManager.CreateStaticRoles(tenant.Id)); await CurrentUnitOfWork.SaveChangesAsync(); //To get static role ids //grant all permissions to admin role var adminRole = _roleManager.Roles.Single(r => r.Name == StaticRoleNames.Tenants.Admin); await _roleManager.GrantAllPermissionsAsync(adminRole); //Create admin user for the tenant var adminUser = User.CreateTenantAdminUser(tenant.Id, input.AdminEmailAddress, User.DefaultPassword); CheckErrors(await UserManager.CreateAsync(adminUser)); await CurrentUnitOfWork.SaveChangesAsync(); //To get admin user's id //Assign admin user to role! CheckErrors(await UserManager.AddToRoleAsync(adminUser.Id, adminRole.Name)); await CurrentUnitOfWork.SaveChangesAsync(); //Assign Default Theme await _settingStore.CreateAsync(Settings.ThemeInitialConfig(tenant.Id)); var theme = await _themeProvider.GetThemeByThemeName(ValueConst.MainTheme, HttpContext.Current.Server); _pymeProvider.SetMainPageContent(theme, false); //Paypal config await _settingStore.CreateAsync(Settings.PayPalInitialConfig(tenant.Id)); await _settingStore.CreateAsync(Settings.PayPalSecretKey(tenant.Id)); } }