Example #1
0
        public async Task <WeatherInfo> GetCurrentConditions(double latitude, double longitude)
        {
            await Task.Delay(10);

            var wi = new WeatherInfo()
            {
                CurrentTemp = 57.2, ForecastDate = DateTimeOffset.Now, Summary = "Partly Cloudy"
            };

            return(wi);
        }
Example #2
0
 public void InsertWeatherInfo(WeatherInfo weather)
 {
     try
     {
         var dbContext = new WeatherInfoDbContext();
         dbContext.WeatherInfo.Add(weather);
         dbContext.SaveChanges();
     }
     catch (Exception e)
     {
         throw new Exception($"Error while saving data. See details, Cannot insert duplicate records.");
     }
 }
Example #3
0
        public async Task <WeatherInfo> GetCurrentConditions(double lat, double longitude)
        {
            var forecast = await GetDarkSkyForecast(lat, longitude);

            var info = new WeatherInfo();

            info.CurrentTemp       = Math.Ceiling(forecast.Currently.ApparentTemperature);
            info.ForecastDate      = forecast.Currently.Time;
            info.Icon              = forecast.Currently.Icon;
            info.PrecipitationType = forecast.Currently.PrecipitationType;
            info.Summary           = forecast.Currently.Summary;

            return(info);
        }