Beispiel #1
0
        public async Task <WeatherModel> GetWeather(string country, string city)
        {
            if (string.IsNullOrWhiteSpace(country))
            {
                throw new ArgumentException(nameof(country));
            }
            if (string.IsNullOrWhiteSpace(city))
            {
                throw new ArgumentException(nameof(city));
            }

            var data = await _serviceProxy.Invoke(c => c.GetWeatherAsync(city, country));

            var mapped = MapData(data);

            return(mapped);
        }
Beispiel #2
0
        public async Task <List <string> > CitiesForCountry(string country)
        {
            var results = new List <string>();

            var data = await _serviceProxy.Invoke(c => c.GetCitiesByCountryAsync(country));

            using (var tr = new StringReader(data))
            {
                var xdoc         = XDocument.Load(tr);
                var cityElements = xdoc.Descendants("City").ToList();

                if (cityElements.Any())
                {
                    results.AddRange(cityElements.Select(e => e.Value.Trim()));
                }

                return(results);
            }
        }