Exemplo n.º 1
0
        public WeatherViewModel()
        {
            UpdateData = new Command(
                execute: () =>
            {
                IsExecuting = true;

                var req = WeatherApi.Get();

                req.Wait();

                var response = req.Result;

                if (response.Successful)
                {
                    var WeatherInfo = JsonConvert.DeserializeObject <WeatherInfo>(response.Content);

                    Console.WriteLine("asdasda");

                    WeatherName = WeatherInfo.weather[0].main;

                    Temperature = WeatherInfo.main.temp;

                    MaxTemperature = WeatherInfo.main.temp_max;

                    MinTemperature = WeatherInfo.main.temp_min;

                    Pressure = WeatherInfo.main.pressure;

                    Humidity = WeatherInfo.main.humidity;
                }

                IsExecuting = false;
            },
                canExecute: () =>
            {
                if (!IsExecuting)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });

            // initial execute
            //UpdateData.Execute(new object());
        }
 public IEnumerable <WeatherForecast> Get()
 {
     return(_api.Get());
 }