Beispiel #1
0
        public async Task SeedAsync()
        {
            _context.Applications.RemoveRange(_context.Applications);
            await _context.SaveChangesAsync();

            Guid testEnvKey = Guid.NewGuid();
            Guid prodEnvKey = Guid.NewGuid();

            await _context.Applications.AddAsync(new Application {
                Key      = DefaultApplicationKey,
                Name     = "MyApp",
                Services = new List <ApplicationService> {
                    new ApplicationService {
                        Key          = DefaultServiceKey,
                        Name         = "Calculation",
                        Environments = new List <ServiceEnvironment> {
                            new ServiceEnvironment {
                                Key = DefaultEnvironmentKey, Name = "Development"
                            },
                            new ServiceEnvironment {
                                Key = testEnvKey, Name = "Test"
                            },
                            new ServiceEnvironment {
                                Key = prodEnvKey, Name = "Production"
                            }
                        }
                    }
                }
            });

            await _client.AddConfigAsync(DefaultApplicationKey, DefaultServiceKey, DefaultEnvironmentKey, "MyConnectionString", "Data Source=UA01WP0257;Initial Catalog=ConfigStorage;Integrated Security=True;MultipleActiveResultSets=True");

            await _client.AddConfigAsync(DefaultApplicationKey, DefaultServiceKey, DefaultEnvironmentKey, "ASPNETCORE_ENVIRONMENT", "Development");

            await _client.AddConfigAsync(DefaultApplicationKey, DefaultServiceKey, testEnvKey, "ASPNETCORE_ENVIRONMENT", "Test");

            await _client.AddConfigAsync(DefaultApplicationKey, DefaultServiceKey, prodEnvKey, "ASPNETCORE_ENVIRONMENT", "Production");

            await _context.SaveChangesAsync();
        }
Beispiel #2
0
        public async Task <IActionResult> AddOrUpdateAsync([FromBody] AddConfigDto addConfigDto)
        {
            if (!ModelState.IsValid)
            {
                return(this.ValidationError());
            }
            Application        app  = this.GetApplication();
            ApplicationService serv = this.GetService();
            ServiceEnvironment env  = this.GetEnvironment();
            await _client.AddConfigAsync(app.Key, serv.Key, env.Key, addConfigDto.ConfigName, addConfigDto.ConfigValue);

            return(Ok());
        }