public async Task <IActionResult> View([FromRoute] Guid applicationId, [FromQuery] Guid?environmentId = null) { ViewData["ApplicationId"] = applicationId; var environments = await environmentService.GetEnvironments(applicationId); ApplicationEnvironment selectedEnvironment = environments.FirstOrDefault(x => x.Id == environmentId); var features = await featureToggleService.GetFeatureToggles(applicationId); if (selectedEnvironment == null) { selectedEnvironment = environments.First(x => x.IsDefault); } var targets = await userTargetingService.GetTargets(selectedEnvironment.Id); return(View(new TargetingViewModel { Environments = environments, FeatureToggles = features, SelectedEnvironment = selectedEnvironment, UserTargetings = targets })); }