コード例 #1
0
        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"
            });
        }