Пример #1
0
        public bool CreateTenant(string tenantName, TenantSettings tenantSettings)
        {
            List <TenantConfiguration> tenants = TenantIOReader.ReadTenantsFromConfigFile();
            var tenant = tenants.Find(x => x.Name == tenantName);

            if (tenant != null)
            {
                return(false);
            }

            var tenantConfiguration = new TenantConfiguration()
            {
                Name = tenantName, Settings = tenantSettings
            };

            tenants.Add(tenantConfiguration);
            if (TenantIOWriter.WriteTenantsConfiguration(tenants) == true)
            {
                _tenantRepository.AddTenantFromApi(tenantConfiguration);
                _storageHubService.CreateTenantAsync(_tenantFactory
                                                     .CreateTenant(tenantConfiguration.Name,
                                                                   tenantConfiguration.Settings.DigitalSignature,
                                                                   tenantConfiguration.Settings.EnableEncryption,
                                                                   tenantConfiguration.Settings.AllowProductCreation,
                                                                   tenantConfiguration.Settings.EnableAuthorization,
                                                                   tenantConfiguration.Settings.Tokens,
                                                                   tenantConfiguration.Settings.Logging,
                                                                   tenantConfiguration.Settings.EnableGeoReplication,
                                                                   tenantConfiguration.Settings.CertificatePath));
                return(true);
            }

            return(false);
        }