async void OnGetWeatherButtonClicked(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(_cityEntry.Text))
            {
                loadingData.IsVisible = true;
                EntitiyData entitiyData = await restService.GetWeatherData(GenerateRequestUri(Constants.Endpoint, "/weather"));

                data = entitiyData;

                BindingContext = data;

                listForecast.ItemsSource = await restService.GetForecastData(GenerateRequestUri(Constants.Endpoint, "/forecast"));

                loadingData.IsVisible = false;
                Console.WriteLine("DEBUG - Button Clicked!");
            }
        }
Beispiel #2
0
        async void getForecast(string cityName)
        {
            ForecastData forecastData = await restService.GetForecastData(GenerateRequestUri(Constants.OpenWeatherMapForecastEndpoint, cityName));

            PageWeather.ForecastData = forecastData;
            MainPageWeather newWether = new MainPageWeather()
            {
                ForecastData = PageWeather.ForecastData,
                WeatherData  = PageWeather.WeatherData
            };

            BindingContext = newWether;
        }
        async void OnGetWeather(string city)
        {
            if (!string.IsNullOrWhiteSpace(city))
            {
                WeatherDataForecast weatherData = await _restService.GetForecastData(GenerateRequestUri(Constants.OpenWeatherMapEndpointForecast, city));

                if (weatherData == null)
                {
                    this.DisplayAlert("", "No internet connection", "OK");
                }
                else
                {
                    weatherData.List[0].Main.Temp = weatherData.List[0].Main.Temp + "°C ";
                    weatherImage.Source           = "http://openweathermap.org/img/w/" + weatherData.List[0].Weather[0].Icon + ".png";
                    Day_0.Text     = System.DateTime.Now.AddDays(1).DayOfWeek.ToString();
                    Day_1.Text     = System.DateTime.Now.AddDays(2).DayOfWeek.ToString();
                    Day_2.Text     = System.DateTime.Now.AddDays(3).DayOfWeek.ToString();
                    BindingContext = weatherData;
                    Application.Current.Properties["city"] = city;
                }
            }
        }