Exemplo n.º 1
0
        public async Task <IActionResult> DeleteConfirmed(string id)
        {
            EnvironmentDetail environment;

            try
            {
                environment = await repository.GetAsync(id).ConfigureAwait(false);

                if (!string.IsNullOrEmpty(environment.AppEndpoint?.ApplicationSecretId))
                {
                    // Remove the secret associated with the Azure AD application from key vault.
                    await vault.DeleteSecretAsync(
                        configuration["KeyVaultEndpoint"],
                        environment.AppEndpoint.ApplicationSecretId).ConfigureAwait(false);
                }

                if (!string.IsNullOrEmpty(environment.PartnerCenterEndpoint?.ApplicationSecretId))
                {
                    // Remove the secret associated with the Partner Center application from key vault.
                    await vault.DeleteSecretAsync(
                        configuration["KeyVaultEndpoint"],
                        environment.PartnerCenterEndpoint.ApplicationSecretId).ConfigureAwait(false);
                }

                await repository.DeleteAsync(id).ConfigureAwait(false);

                return(RedirectToAction("Index"));
            }
            finally
            {
                environment = null;
            }
        }