public async Task <Environment> GetCurrentEnvironment() { var allEnvironments = await GetAll(); var selectedEnvironmentName = _urlService.GetEnvironment(); var selectedEnvironment = allEnvironments.FirstOrDefault(x => x.Name == selectedEnvironmentName); if (selectedEnvironment != null) { return(selectedEnvironment); } if (allEnvironments.Count > 0) { return(allEnvironments[0]); } return(new Environment() { Id = 0, Name = "Default" }); }