Beispiel #1
0
        private async Task AddConfiguration(
            string tenantName,
            string configurationName)
        {
            ITenantStore tenantStore =
                ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>();
            ITenantProvider tenantProvider = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantProvider>();

            ITenant tenant = await tenantProvider.GetTenantAsync(this.scenarioContext.Get <string>(tenantName)).ConfigureAwait(false);

            List <ConfigurationItem> configuration = this.scenarioContext.Get <List <ConfigurationItem> >(configurationName);

            await CatchException.AndStoreInScenarioContextAsync(
                this.scenarioContext,
                () => tenantStore.AddOrUpdateStorageConfigurationAsync(
                    tenant,
                    configuration.ToArray())).ConfigureAwait(false);
        }
        /// <summary>
        /// Add or updates arbitrary storage configuration for a tenant.
        /// </summary>
        /// <param name="tenantStore">The <see cref="ITenantStore"/>.</param>
        /// <param name="tenantId">The ID of the tenant to enroll.</param>
        /// <param name="configurationItems">Configuration to add.</param>
        /// <returns>A task which completes when the configuration has been added.</returns>
        public static async Task AddOrUpdateStorageConfigurationAsync(
            this ITenantStore tenantStore,
            string tenantId,
            ConfigurationItem[] configurationItems)
        {
            if (string.IsNullOrWhiteSpace(tenantId))
            {
                throw new ArgumentException(nameof(tenantId));
            }

            if (configurationItems == null)
            {
                throw new ArgumentNullException(nameof(configurationItems));
            }

            ITenant tenant = await tenantStore.GetTenantOfTypeAsync(
                tenantId,
                MarainTenantType.Client).ConfigureAwait(false);

            await tenantStore.AddOrUpdateStorageConfigurationAsync(tenant, configurationItems).ConfigureAwait(false);
        }