public async Task <IActionResult> Remove([FromBody] KeyDto keyDto) { if (!ModelState.IsValid) { return(this.ValidationError()); } Application app = this.GetApplication(); ApplicationService service = await _context.Services.FirstOrDefaultAsync(serv => serv.Key == keyDto.Key); if (service == null) { return(StatusCode((int)HttpStatusCode.Unauthorized)); } List <ServiceEnvironment> envs = await _context.Environments.Where(env => env.ServiceId == service.Id).ToListAsync(); IEnumerable <Task> removeConfigTasks = envs.Select(async env => await _client.RemoveConfigsAsync(app.Key, service.Key, env.Key)); await Task.WhenAll(removeConfigTasks); _context.Services.Remove(service); await _context.SaveChangesAsync(); return(Ok()); }
public async Task <IActionResult> Remove([FromBody] KeyDto keyDto) { if (!ModelState.IsValid) { return(this.ValidationError()); } Application application = this.GetApplication(); ApplicationService service = this.GetService(); ServiceEnvironment environment = await _context.Environments.FirstOrDefaultAsync(env => env.Key == keyDto.Key); if (environment == null) { return(StatusCode((int)HttpStatusCode.Unauthorized)); } await _client.RemoveConfigsAsync(application.Key, service.Key, environment.Key); _context.Environments.Remove(environment); await _context.SaveChangesAsync(); return(Ok()); }