private Task <OpenWeatherMap.CurrentWeatherResponse> DoFallbackAction(CancellationToken ct, string city)
        {
            // TODO get weather from a real cache
            OpenWeatherMap.CurrentWeatherResponse response = new OpenWeatherMap.CurrentWeatherResponse()
            {
                Weather = new OpenWeatherMap.Weather()
                {
                    Value = "cloudy"
                },
                Temperature = new OpenWeatherMap.Temperature()
                {
                    Value = 11.11, Unit = "celcius"
                },
                City = new OpenWeatherMap.City()
                {
                    Name = city + " (fallback)"
                },
            };

            var resultTask = new Task <OpenWeatherMap.CurrentWeatherResponse>(() => response);

            resultTask.Start();

            return(resultTask);
        }
 private Weather GetWeatherFromResponse(OpenWeatherMap.CurrentWeatherResponse currentWeather)
 {
     return(new Weather()
     {
         City = currentWeather.City.Name,
         Temperature = new Temperature(currentWeather.Temperature.Value),
         Value = currentWeather.Weather.Value
     });
 }
        public static Weather GetWeatherFromResponse(OpenWeatherMap.CurrentWeatherResponse currentWeather)
        {
            var weather = new Weather()
            {
                City        = currentWeather.City.Name,
                Temperature = new Temperature(currentWeather.Temperature.Value),
                Value       = currentWeather.Weather.Value,
                ASCIIWeatherRepresentation = GetASCIIWeatherRepresentation(currentWeather)
            };

            return(weather);
        }
Esempio n. 4
0
        public static WeatherCondition ToWeatherCondition(this OpenWeatherMap.CurrentWeatherResponse response)
        {
            var weatherCondition = new WeatherCondition
            {
                CityName           = response.City.Name,
                MinimumTemperature = response.Temperature.Min,
                MaximumTemperature = response.Temperature.Max,
                Temperature        = response.Temperature.Value,
                WindSpeed          = response.Wind.Speed.Value,
                Precipitation      = response.Precipitation.Value,
                Humidity           = response.Humidity.Value,
                SunSet             = response.City.Sun.Set,
                SunRise            = response.City.Sun.Rise
            };

            return(weatherCondition);
        }
        private static ASCIIWeatherRepresentation GetASCIIWeatherRepresentation(OpenWeatherMap.CurrentWeatherResponse currentWeather)
        {
            string asciiCode = ASCIIWeatherMap.GetASCIIFromOpenWeatherResponse(currentWeather);

            return(new ASCIIWeatherRepresentation(asciiCode));
        }
        public static string GetASCIIFromOpenWeatherResponse(OpenWeatherMap.CurrentWeatherResponse response)
        {
            int key = response.Weather.Number;

            return(GetASCIIFromOpenWeatherResponse(key));
        }