Exemple #1
0
        private async Task WriteSecretConfiguration(OdsSecretConfiguration configuration, int?instanceRegistrationId)
        {
            var stringValue    = Json.Encode(configuration);
            var encryptedValue = _stringEncryptorService.Encrypt(stringValue);

            using (var database = new AdminAppDbContext())
            {
                var secretConfiguration =
                    await database.SecretConfigurations.SingleOrDefaultAsync(x =>
                                                                             x.OdsInstanceRegistrationId == instanceRegistrationId);

                if (secretConfiguration == null)
                {
                    database.SecretConfigurations.Add(new SecretConfiguration
                    {
                        EncryptedData = encryptedValue, OdsInstanceRegistrationId = instanceRegistrationId
                    });
                }
                else
                {
                    secretConfiguration.EncryptedData = encryptedValue;
                }

                await database.SaveChangesAsync();
            }
        }
Exemple #2
0
        private async Task WriteSecretConfiguration(OdsSecretConfiguration configuration, int? instanceRegistrationId)
        {
            var stringValue = JsonConvert.SerializeObject(configuration, GetSerializerSettings());
            var encryptedValue = _stringEncryptorService.Encrypt(stringValue);

            var secretConfiguration =
                await _database.SecretConfigurations.SingleOrDefaultAsync(x =>
                    x.OdsInstanceRegistrationId == instanceRegistrationId);
            if (secretConfiguration == null)
                _database.SecretConfigurations.Add(new SecretConfiguration
                    {EncryptedData = encryptedValue, OdsInstanceRegistrationId = instanceRegistrationId});
            else
                secretConfiguration.EncryptedData = encryptedValue;

            await _database.SaveChangesAsync();
        }