Exemplo n.º 1
0
        async public Task <string> GenerateForcastMessageDaily(string location, DateTime?startdate = null)
        {
            try
            {
                var geo = await ServiceManager.GeoService.QueryGeoInfoByLocation(location);

                if (geo != null)
                {
                    OptionalParameters param = new OptionalParameters {
                        MeasurementUnits = "uk2"
                    };
                    if (startdate != null && startdate.HasValue)
                    {
                        param = new OptionalParameters {
                            ForecastDateTime = startdate, ExtendHourly = false, MeasurementUnits = "uk2"
                        };
                    }

                    var response = await _darkSky.GetForecast(geo.Latitude, geo.Longitude, param);

                    if (response.IsSuccessStatus)
                    {
                        string message = $"In {geo.Location}, {response.Response.Daily.Summary}";
                        if (startdate != null && startdate.HasValue)
                        {
                            message = $"At {geo.Location} on {startdate.Value.ToString("d")}, {response.Response.Hourly.Summary}";
                            if (response.Response.Currently.Temperature.HasValue)
                            {
                                message += $" The average temperature will be {response.Response.Currently.Temperature.Value}°C.";
                            }
                            if (response.Response.Currently.Humidity.HasValue)
                            {
                                message += $" The humidity will be around {response.Response.Currently.Humidity.Value*100}%.";
                            }
                            message += ".";
                        }

                        return(message);
                    }
                    else
                    {
                        return(response.ResponseReasonPhrase);
                    }
                }
                else
                {
                    throw new Exception($"Failed to find a location as {location}.");
                }
            }
            catch (Exception err)
            {
                return(err.Message);
            }
        }
Exemplo n.º 2
0
        public async Task CacheControlHeaderNullValueTest()
        {
            var forecast = await _darkSky.GetForecast(_latitude, _longitude);

            Assert.NotNull(forecast.Headers);
            Assert.NotNull(forecast.Headers.CacheControl);
        }
Exemplo n.º 3
0
        // GET: Parks/Details/{id}
        public async Task <IActionResult> Details(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            else
            {
                var park = await _context.Parks.FirstOrDefaultAsync(m => m.ParkCode == id);

                if (park == null)
                {
                    return(NotFound());
                }
                else
                {
                    // Forecast - "daily" data block with 8 data points for 8 days of weather
                    Forecast forecast = await darkSky.GetForecast(park);

                    // Creates Weather objects for each day
                    park.DaysOfWeather = darkSky.GetWeatherForWeek(park, forecast);
                    return(View(park));
                }
            }
        }
Exemplo n.º 4
0
        public async Task GetForecastWithMockData()
        {
            var darkSkyService = new DarkSkyService("fakekey", _fixture.MockClient.Object);
            var forecast       = await darkSkyService.GetForecast(_latitude, _longitude);

            Assert.NotNull(forecast);

            //Check Response (basic deserialization check)
            Assert.NotNull(forecast.Response);
            Assert.Equal(forecast.Response.Latitude, _latitude);
            Assert.Equal(forecast.Response.Longitude, _longitude);
            Assert.NotEmpty(forecast.Response.Alerts);
            Assert.NotNull(forecast.Response.Currently);
            Assert.NotNull(forecast.Response.Daily);
            Assert.NotEmpty(forecast.Response.Daily.Data);
            Assert.NotNull(forecast.Response.Flags);
            Assert.NotNull(forecast.Response.Hourly);
            Assert.NotEmpty(forecast.Response.Hourly.Data);
            Assert.NotNull(forecast.Response.Minutely);
            Assert.NotEmpty(forecast.Response.Minutely.Data);
            Assert.NotNull(forecast.Response.Timezone);

            // Check Headers (match pre-defined values)
            Assert.NotNull(forecast.Headers);
            Assert.Equal(forecast.Headers.ApiCalls.Value, _fixture.ApiCalls);
            Assert.Equal(forecast.Headers.CacheControl.MaxAge.Value.TotalMinutes, _fixture.CacheMinutes);
            Assert.Equal(forecast.Headers.ResponseTime, _fixture.ResponseTime);
        }
Exemplo n.º 5
0
        public async Task BuffaloForecastCombineAllOptionsGermanCulture()
        {
            using var germanCultureParse =
                      new DarkSkyService(_apiKey, jsonSerializerService: new CultureSettingFixture());

            var forecast = await germanCultureParse.GetForecast(_latitude, _longitude,
                                                                new OptionalParameters
            {
                ExtendHourly        = true,
                DataBlocksToExclude = new List <ExclusionBlocks> {
                    ExclusionBlocks.Flags
                },
                LanguageCode     = "x-pig-latin",
                MeasurementUnits = "si"
            });

            Assert.NotNull(forecast);
            Assert.NotNull(forecast.Response);
            Assert.NotNull(forecast.Headers);
            Assert.NotEmpty(forecast.Response.Daily.Data);
            Assert.NotEmpty(forecast.Response.Hourly.Data);
            Assert.Null(forecast.Response.Flags);
            Assert.Equal(forecast.Response.Latitude, _latitude);
            Assert.Equal(forecast.Response.Longitude, _longitude);
        }
        public async Task GetForecastWithMockData()
        {
            var mockCLient = new Mock <IHttpClient>();

            mockCLient.Setup(f => f.HttpRequest(It.IsAny <string>())).Returns(Task.FromResult(_mockHttpResponse));

            var darkSkyService = new DarkSkyService("fakekey", mockCLient.Object);
            var forecast       = await darkSkyService.GetForecast(_latitude, _longitude);

            Assert.NotNull(forecast);

            // Check Response (basic deserialization check)
            Assert.NotNull(forecast.Response);
            Assert.Equal(forecast.Response.Latitude, _latitude);
            Assert.Equal(forecast.Response.Longitude, _longitude);
            Assert.NotEmpty(forecast.Response.Alerts);
            Assert.NotNull(forecast.Response.Currently);
            Assert.NotNull(forecast.Response.Daily);
            Assert.NotEmpty(forecast.Response.Daily.Data);
            Assert.NotNull(forecast.Response.Flags);
            Assert.NotNull(forecast.Response.Hourly);
            Assert.NotEmpty(forecast.Response.Hourly.Data);
            Assert.NotNull(forecast.Response.Minutely);
            Assert.NotEmpty(forecast.Response.Minutely.Data);
            Assert.NotNull(forecast.Response.TimeZone);
        }
Exemplo n.º 7
0
        public async Task BuffaloForecastEverythingParsed()
        {
            using var parseAllJson =
                      new DarkSkyService(_apiKey, jsonSerializerService: new MissingMemberHandlingFixture());

            await parseAllJson.GetForecast(_latitude, _longitude);
        }
Exemplo n.º 8
0
        public string GetWeatherForLocation(double latitude, double longitude)
        {
            var service  = new DarkSkyService("97fb52ad1c8fb2f59ff1f5da02d0337c");
            var forecast = Task.Run(() => service.GetForecast(latitude, longitude)).Result;

            return($"Current weather is {forecast.Response.Currently.Temperature}");
        }
Exemplo n.º 9
0
        public void FullQueryBuilderTest()
        {
            var expectedQuery =
                $"forecast/fakekey/{ResponseFixture.Latitude},{ResponseFixture.Longitude},1970-01-01T00:00:00Z?&exclude=alerts,flags&extend=hourly&lang=x-pig-latin&units=si";
            const string baseUri    = @"https://api.darksky.net/";
            var          totalQuery = $"{baseUri}{expectedQuery}";

            var queryCheckClient = new Mock <IHttpClient>();

            queryCheckClient.Setup(f => f.HttpRequestAsync(totalQuery))
            .Returns((string s) => Task.FromResult(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK, ReasonPhrase = s
            }));

            using var darkSkyServiceQueryCheck =
                      new DarkSkyService("fakekey", new Uri(baseUri), queryCheckClient.Object);
            var parameters = new OptionalParameters
            {
                DataBlocksToExclude = new List <ExclusionBlocks> {
                    ExclusionBlocks.Alerts, ExclusionBlocks.Flags
                },
                ExtendHourly     = true,
                LanguageCode     = "x-pig-latin",
                MeasurementUnits = "si",
                ForecastDateTime = DateTime.UnixEpoch
            };
            var result = darkSkyServiceQueryCheck
                         .GetForecast(ResponseFixture.Latitude, ResponseFixture.Longitude, parameters).Result;

            Assert.Equal(result.ResponseReasonPhrase, totalQuery);
            Assert.True(result.IsSuccessStatus);
        }
Exemplo n.º 10
0
        public async Task TestGetBasicWeatherData()
        {
            var api = Config[_apiEnvVar];

            Assert.IsNotNull(api);

            var weather = new DarkSkyService(api);

            var forecast = await weather.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
            {
                MeasurementUnits = "si",
            });

            var humid = forecast.Response.Currently.Humidity;

            var temp = forecast.Response.Currently.Temperature;

            var wind = forecast.Response.Currently.WindSpeed;

            var minToday = forecast.Response.Daily.Data[0].TemperatureLow;
            var maxToday = forecast.Response.Daily.Data[0].TemperatureHigh;

            var minTomorrow = forecast.Response.Daily.Data[1].TemperatureLow;
            var maxTomorrow = forecast.Response.Daily.Data[1].TemperatureHigh;

            foreach (var day in forecast.Response.Daily.Data)
            {
                var time = day.DateTime.ToLocalTime();
                Debug.WriteLine(time.ToString());
            }


            Debug.WriteLine($"Temp: {temp}, Humid: {humid}");
        }
Exemplo n.º 11
0
        public async Task <RuntimeResult> GetWeatherForLocationAsync([Summary("Location")][Remainder] string location)
        {
            var geocodeResults = await Geocoder.GeocodeAsync(location).ConfigureAwait(false);

            var geocode = geocodeResults.FirstOrDefault();

            if (geocode == null)
            {
                return(CommandRuntimeResult.FromError($"I could not find {location}! Try another location."));
            }
            var forecast = await DarkSkyService.GetForecast(
                geocode.Coordinates.Latitude,
                geocode.Coordinates.Longitude,
                _darkSkyParams).ConfigureAwait(false);

            var embeds = await Weather.GetWeatherEmbedsAsync(forecast, geocode).ConfigureAwait(false);

            await ReplyAsync("", embed : embeds.WeatherResults.FirstOrDefault().Build()).ConfigureAwait(false);

            foreach (var alert in embeds.Alerts)
            {
                await ReplyAsync("", embed : alert.Build()).ConfigureAwait(false);
            }
            return(CommandRuntimeResult.FromSuccess());
        }
Exemplo n.º 12
0
        public async Task <RuntimeResult> GetWeatherForLocationAsync([Summary("User")] SocketUser user = null)
        {
            var targetUser = user ?? Context.User;
            var record     = UserRepository.GetCoordinates(targetUser);

            if (record == null)
            {
                return(CommandRuntimeResult.FromError(
                           "Location is not set yet! Please set the location first!"));
            }
            var geocodeResults = await Geocoder.ReverseGeocodeAsync(record.Latitude, record.Longitude).ConfigureAwait(false);

            var geocode = geocodeResults.FirstOrDefault();

            if (geocode == null)
            {
                return(CommandRuntimeResult.FromError(
                           "I could not find the set location! Try setting another location."));
            }
            var forecast = await DarkSkyService.GetForecast(
                geocode.Coordinates.Latitude,
                geocode.Coordinates.Longitude,
                _darkSkyParams
                ).ConfigureAwait(false);

            var embeds = await Weather.GetWeatherEmbedsAsync(forecast, geocode).ConfigureAwait(false);

            await ReplyAsync("", embed : embeds.WeatherResults.FirstOrDefault().Build()).ConfigureAwait(false);

            foreach (var alert in embeds.Alerts)
            {
                await ReplyAsync("", embed : alert.Build()).ConfigureAwait(false);
            }
            return(CommandRuntimeResult.FromSuccess());
        }
Exemplo n.º 13
0
        public async void GetForecast_ByCoordinates_Test()
        {
            // prepare
            Forecast output = null;

            using (var stream = new BufferedStream(File.OpenRead("./Resources/DarkSky_GetForecast_SI.json"), 8192)) {
                var mockHttp = new MockHttpMessageHandler();
                mockHttp
                .When(DarkSkyService.EndPointRoot + "*")
                .Respond("application/json", stream);
                IDarkSkyService client = new DarkSkyService("a_valid_key", mockHttp);

                output = await client.GetForecast(BolognaLatitude, BolognaLongitude, DSUnit.SI, Language.Italian);

                stream.Close();
            }

            // assert
            Assert.NotNull(output);
            Assert.NotNull(output.Currently);
            Assert.Null(output.Minutely);
            Assert.NotNull(output.Hourly);
            Assert.NotNull(output.Hourly.Data);
            Assert.NotEmpty(output.Hourly.Data);
            Assert.NotNull(output.Daily);
            Assert.NotNull(output.Daily.Data);
            Assert.NotEmpty(output.Daily.Data);
        }
Exemplo n.º 14
0
        private async void GetWeather()
        {
            var forecast = await _darkSkyService.GetForecast(_config.Latitude, _config.Longitude,
                                                             new DarkSkyService.OptionalParameters
            {
                ExtendHourly        = true,
                DataBlocksToExclude = new List <ExclusionBlock> {
                    ExclusionBlock.Flags
                },
                LanguageCode     = "x-pig-latin",
                MeasurementUnits = "si"
            });

            _logger.LogInformation(
                $"{forecast.Response.Currently.Icon} Temperature {forecast.Response.Currently.Temperature} - Humidity {forecast.Response.Currently.Humidity * 100}%");


            var entity = new WeatherEd
            {
                EntityName    = "Weather",
                EventDateTime = DateTime.Now,
                Humidity      = forecast.Response.Currently.Humidity.Value,
                Temperature   = forecast.Response.Currently.Temperature.Value,
                Pressure      = forecast.Response.Currently.Pressure.Value,
                WindBearing   = forecast.Response.Currently.WindBearing.Value,
                UvIndex       = forecast.Response.Currently.UvIndex.Value,
                WindGust      = forecast.Response.Currently.WindGust.Value,
                WindSpeed     = forecast.Response.Currently.WindSpeed.Value,
                Status        = forecast.Response.Currently.Icon.ToString()
            };

            _ioTService.InsertEvent(entity);
        }
 public void ExceptionThrownForMissingApiKey(string value)
 {
     Assert.ThrowsAny <ArgumentException>(() =>
     {
         var darkSkyService = new DarkSkyService(value);
         var result         = darkSkyService.GetForecast(0, 0);
     });
 }
Exemplo n.º 16
0
        public async Task GetForecast()
        {
            var forecast = _forecastService.GetForecast(59.2924, 18.2455).Result.Response;

            //var current = forecast.Currently;
            //var minutely = forecast.Minutely;
            //var hourly = forecast.Hourly;
            //var daily = forecast.Daily;
            await Clients.All.InvokeAsync("OnWeatherUpdate", forecast);
        }
Exemplo n.º 17
0
        public async Task <string> GetForecast(string longitude, string latitude)
        {
            DarkSkyService darkSkyService = new DarkSkyService("bb113d05c9be235ad2edae74a9ad6075");
            string         rtn;

            var temp = await darkSkyService.GetForecast(double.Parse(latitude), double.Parse(longitude));

            rtn = JsonConvert.SerializeObject(temp);
            return(rtn);
        }
Exemplo n.º 18
0
        public static async Task <Forecast> GetForecast(double latitude, double longitude)
        {
            var result = await DarkSkyHandle.GetForecast(latitude, longitude);

            if (result.IsSuccessStatus)
            {
                return(result.Response);
            }
            throw new ServiceException(result.ResponseReasonPhrase);
        }
        public async Task HandleInvalidApiKey()
        {
            // Use a different client to create one with an invalid API key.
            var client = new DarkSkyService("ThisIsAFakeKey");

            var forecast = await client.GetForecast(_latitude, _longitude);

            Assert.NotNull(forecast);
            Assert.False(forecast.IsSuccessStatus);
            Assert.NotEmpty(forecast.ResponseReasonPhrase);
        }
Exemplo n.º 20
0
        private DarkSkyResponse GetWeather()
        {
            DarkSkyResponse result         = null;
            var             getWeatherTask = new TaskFactory().StartNew(
                () =>
            {
                var client = new DarkSkyService(ApiKey);
                result     = client.GetForecast(this.latitude, this.longitude).Result;
            });

            getWeatherTask.Wait();
            return(result);
        }
        public async Task ApiCallsHeaderMissingTest()
        {
            var mockCLient = new Mock <IHttpClient>();

            mockCLient.Setup(f => f.HttpRequest(It.IsAny <string>())).Returns(Task.FromResult(_mockHttpResponse));

            var darkSkyService = new DarkSkyService("fakekey", mockCLient.Object);
            var forecast       = await darkSkyService.GetForecast(_latitude, _longitude);

            // Check Headers (match pre-defined values)
            Assert.NotNull(forecast.Headers);
            Assert.Null(forecast.Headers.ApiCalls);
        }
Exemplo n.º 22
0
        public async Task BuffaloForecastCombineAllOptions()
        {
            var forecast = await _darkSky.GetForecast(_latitude, _longitude,
                                                      new OptionalParameters
            {
                ExtendHourly        = true,
                DataBlocksToExclude = new List <ExclusionBlocks> {
                    ExclusionBlocks.Flags
                },
                LanguageCode     = "x-pig-latin",
                MeasurementUnits = "si"
            });

            Assert.NotNull(forecast);
            Assert.NotNull(forecast.Response);
            Assert.NotNull(forecast.Headers);
            Assert.NotEmpty(forecast.Response.Daily.Data);
            Assert.NotEmpty(forecast.Response.Hourly.Data);
            Assert.Null(forecast.Response.Flags);
            Assert.Equal(forecast.Response.Latitude, _latitude);
            Assert.Equal(forecast.Response.Longitude, _longitude);
        }
Exemplo n.º 23
0
        public ResponseFixture()
        {
            var mockClient = new Mock <IHttpClient>();

            mockClient.Setup(f => f.HttpRequestAsync(It.IsAny <string>())).Returns(Task.FromResult(MockHttpResponse));

            using (var darkSkyService = new DarkSkyService("fakekey", httpClient: mockClient.Object))
            {
                NormalResponse = darkSkyService.GetForecast(Latitude, Longitude).Result;
            }

            var mockMissingDataClient = new Mock <IHttpClient>();

            mockMissingDataClient.Setup(f => f.HttpRequestAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(MockHttpResponseMissingData));

            using (var darkSkyServiceMissingData =
                       new DarkSkyService("fakekey", httpClient: mockMissingDataClient.Object))
            {
                MissingDataResponse = darkSkyServiceMissingData.GetForecast(Latitude, Longitude).Result;
            }

            var invalidKeyClient = new Mock <IHttpClient>();

            invalidKeyClient.Setup(f => f.HttpRequestAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(MockHttpResponseInvalidKey));

            using (var darkSkyServiceForbidden = new DarkSkyService("fakekey", httpClient: invalidKeyClient.Object))
            {
                ForbiddenResponse = darkSkyServiceForbidden.GetForecast(Latitude, Longitude).Result;
            }

            var badDataClient = new Mock <IHttpClient>();

            badDataClient.Setup(f => f.HttpRequestAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(MockHttpResponseBadData));

            using (var darkSkyServiceBadData = new DarkSkyService("fakekey", httpClient: badDataClient.Object))
            {
                BadDataResponse = darkSkyServiceBadData.GetForecast(Latitude, Longitude).Result;
            }

            var alertDataClient = new Mock <IHttpClient>();

            alertDataClient.Setup(f => f.HttpRequestAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(MockHttpResponseAlertData));

            using var darkSkyServiceAlertData = new DarkSkyService("fakekey", httpClient: alertDataClient.Object);
            AlertResponse = darkSkyServiceAlertData.GetForecast(Latitude, Longitude).Result;
        }
Exemplo n.º 24
0
        public async Task BuffaloForecastCombineAllOptions()
        {
            var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
            {
                ExtendHourly        = true,
                DataBlocksToExclude = new List <string> {
                    "flags"
                },
                LanguageCode     = "x-pig-latin",
                MeasurementUnits = "si"
            });

            Assert.NotNull(forecast);
            Assert.NotNull(forecast.Response);
            Assert.NotNull(forecast.Headers);
            Assert.Equal(forecast.Response.Daily.Data.Count, 8);
            Assert.Equal(forecast.Response.Hourly.Data.Count, 169);
            Assert.Null(forecast.Response.Flags);
            Assert.Equal(forecast.Response.Latitude, _latitude);
            Assert.Equal(forecast.Response.Longitude, _longitude);
        }
Exemplo n.º 25
0
        public override async Task Poll()
        {
            var forecast = await _darkSkyService.GetForecast(_homeConfig.CoordinateConfig.Latitude,
                                                             _homeConfig.CoordinateConfig.Longitude, new OptionalParameters()
            {
                LanguageCode     = Config.LanguageCode,
                MeasurementUnits = Config.MeasurementUnits
            });

            if (forecast.IsSuccessStatus)
            {
                var entity = BuildEntity <WeatherEvent>();

                entity.Icon    = forecast.Response.Currently.Icon.ToString();
                entity.Summary = forecast.Response.Currently.Summary;

                if (forecast.Response.Currently.Temperature != null)
                {
                    entity.Temperature = forecast.Response.Currently.Temperature.Value;
                }

                if (forecast.Response.Currently.Humidity != null)
                {
                    entity.Humidity = forecast.Response.Currently.Humidity.Value * 100;
                }

                if (forecast.Response.Currently.Pressure != null)
                {
                    entity.Pressure = forecast.Response.Currently.Pressure.Value;
                }

                if (forecast.Response.Currently.PrecipProbability != null)
                {
                    entity.PrecipProbability = forecast.Response.Currently.PrecipProbability.Value * 100;
                }

                entity.PrecipType = forecast.Response.Currently.PrecipType.ToString();

                PublishEntity(entity);
            }
            else
            {
                Logger.LogWarning("Error during get forecast");
            }


            await base.Poll();
        }
        public async Task DailyBlockEmptyTest()
        {
            var mockCLient = new Mock <IHttpClient>();

            mockCLient.Setup(f => f.HttpRequest(It.IsAny <string>())).Returns(Task.FromResult(_mockHttpResponseMissingData));

            var darkSkyService = new DarkSkyService("fakekey", mockCLient.Object);
            var forecast       = await darkSkyService.GetForecast(_latitude, _longitude);

            Assert.NotNull(forecast);

            // Check Response (basic deserialization check)
            Assert.NotNull(forecast.Response);
            Assert.NotNull(forecast.Response.Daily);
            Assert.Null(forecast.Response.Daily.Data);
        }
Exemplo n.º 27
0
        public async Task <string> GetWeatherConditionsAsync(DateTime date, double latitude, double longitude)
        {
            var result = Messages.WatherConditionsAreNotAvailable;

            var optionalParameters = new OptionalParameters()
            {
                ForecastDateTime = date
            };
            var forecast = await _darkSkyService.GetForecast(latitude, longitude, optionalParameters);

            if (forecast?.IsSuccessStatus == true)
            {
                result = forecast.Response.Currently.Summary;
            }

            return(result);
        }
Exemplo n.º 28
0
        public ResponseFixture()
        {
            var mockClient = new Mock <IHttpClient>();

            mockClient.Setup(f => f.HttpRequest(It.IsAny <string>())).Returns(Task.FromResult(MockHttpResponse));

            var darkSkyService = new DarkSkyService("fakekey", mockClient.Object);

            NormalResponse = darkSkyService.GetForecast(Latitude, Longitude).Result;

            var mockMissingDataCLient = new Mock <IHttpClient>();

            mockMissingDataCLient.Setup(f => f.HttpRequest(It.IsAny <string>())).Returns(Task.FromResult(MockHttpResponseMissingData));

            var darkSkyServiceMissingData = new DarkSkyService("fakekey", mockMissingDataCLient.Object);

            MissingDataResponse = darkSkyServiceMissingData.GetForecast(Latitude, Longitude).Result;
        }
        public async Task <ActionResult <Forecast> > Handle(GetCityForecastRequest request,
                                                            CancellationToken cancellationToken)
        {
            _geocodeRequest.Address    = $"{request.Model.City}, {request.Model.State}";
            _geocodeRequest.Components = new[] { new KeyValuePair <Component, string>(Component.Country, "US") };

            var geocodeData = await GoogleMaps.AddressGeocode.QueryAsync(_geocodeRequest, cancellationToken);

            var location = geocodeData.Results.FirstOrDefault()?.Geometry.Location;

            if (location == null)
            {
                return(new BadRequestResult());
            }

            var cityForecast = await _weatherService.GetForecast(location.Latitude, location.Longitude);

            return(cityForecast.Response);
        }
        private async Task GetWeatherInfo()
        {
            string         apiKey  = "7b2386b7eb27edfe56672ce1520b8893";
            DarkSkyService weather = new DarkSkyService(apiKey);

            DarkSkyService.OptionalParameters optParams = GetUnitOfMeasure();
            var foreCast = await weather.GetForecast(Latt, Long, optParams);

            string iconFileName = GetCurrentWeatherIcon(foreCast.Response.Currently.Icon);
            string svgFile      = Path.Combine(_hostEnv.ContentRootPath, "climacons", iconFileName);

            CurrentWeatherIcon = System.IO.File.ReadAllText($"{svgFile}");
            WeatherAttribution = foreCast.AttributionLine;
            DayWeatherSummary  = foreCast.Response.Daily.Summary;

            if (foreCast.Response.Currently.Temperature.HasValue)
            {
                CurrentTemp = Math.Round(foreCast.Response.Currently.Temperature.Value, 0).ToString();
            }
        }