Beispiel #1
0
        /// <summary>
        /// Saves the current weather
        /// </summary>
        /// <param name="weather">The weather</param>
        public static void InsertWeatherData(WeatherMainModel weather)
        {
            var calculationDate = Helper.FromUnixUtc(weather.Dt);

            if (ExistEntry(calculationDate))
            {
                return;
            }

            const string query =
                "INSERT INTO weatherData (location, weatherMain, weatherDescription, temperature, " +
                "temperaturemin, temperaturemax, pressure, humidity, calculationDate, rain, snow) " +
                "VALUES (@location, @main, @description, @temp, @min, @max, @pressure, @humidity, @date, @rain, @snow)";

            Connector.Connection.Execute(query, new
            {
                location    = weather.Name,
                main        = weather.Weather[0]?.Main ?? "",
                description = weather.Weather[0]?.Description ?? "",
                temp        = weather.Main.Temp,
                min         = weather.Main.TempMin,
                max         = weather.Main.TempMax,
                pressure    = weather.Main.Pressure,
                humidity    = weather.Main.Humidity,
                date        = calculationDate,
                rain        = weather.Rain?.OneHour ?? 0,
                snow        = weather.Snow?.OneHour ?? 0
            });
        }
 /// <summary>
 /// Sets the weather
 /// </summary>
 /// <param name="weather">The current weather</param>
 public void SetWeather(WeatherMainModel weather)
 {
     if (DataContext is WeatherControlViewModel viewModel)
     {
         viewModel.SetWeather(weather);
     }
 }
Beispiel #3
0
 private void LoadWeather()
 {
     try
     {
         if (_weatherMainModel is null)
         {
             _weatherMainModel = WeatherService.GetWeather(Id);
         }
     }
     catch
     {
     }
 }
        private async Task InitializeGetWeatherAsync()
        {
            try
            {
                IsBusy           = true; // set the ui property "IsRunning" to true(loading) in Xaml ActivityIndicator Control
                WeatherMainModel = await _weatherServices.GetCurrentWeather(_city);

                System.Diagnostics.Debug.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!" + WeatherMainModel.ToString());
            }
            finally
            {
                IsBusy = false;
            }
        }
 /// <summary>
 /// Sets the weather control
 /// </summary>
 /// <param name="weather">The current weather</param>
 private void SetWeatherControl(WeatherMainModel weather)
 {
     Dispatcher.Invoke(() => WeatherView.SetWeather(weather));
 }