Beispiel #1
0
        public override async Task <CommandResult> Execute()
        {
            await Task.CompletedTask;

            var locations = dataService.GetWeatherLocations();

            Logger.Trace("Got Locations", locations);
            var forecasts = locations.Locations.Select(l => dataService.GetMostRecentForecast(l.Identifier)).ToList();

            Logger.Trace("Forcasts", forecasts);

            return(CommandResult.CreateSuccessResult(new { locations, forecasts }));
        }
        public override async Task <CommandResult> Execute()
        {
            var doc           = documentStore.GetWeatherLocations();
            var apiKeySetting = await userSettingsDataService.GetUserSetting(Constants.UserSettings.DarkSkyApiKey);

            var results = new List <string>();

            foreach (var location in doc.Locations)
            {
                var forecast = await weatherService.GetForecast(apiKeySetting.value, location.Latitude, location.Longitude);

                Logger.Trace("got forecast", forecast);
                documentStore.UpdateForecast(location, forecast);
                results.Add($"Upserted {location.Identifier}");
            }

            return(CommandResult.CreateSuccessResult(results));
        }
Beispiel #3
0
        public override async Task <CommandResult> Execute()
        {
            await Task.CompletedTask;
            var location = new WeatherLocation
            {
                Name       = Name,
                Identifier = Identifier,
                Latitude   = Latitude,
                Longitude  = Longitude
            };

            var doc = documentStore.GetWeatherLocations();

            if (doc.Locations.All(l => l.Identifier != Identifier))
            {
                doc.Locations.Add(location);
                documentStore.UpdateLocations(doc);
            }

            return(CommandResult.SuccessfulResult);
        }
        private void BootstrapWeatherDoc()
        {
            var current = weatherDocStore.GetWeatherLocations();

            if (current == null)
            {
                var defaultLocations = new WeatherLocations
                {
                    Locations = new List <WeatherLocation>
                    {
                        new WeatherLocation
                        {
                            Name       = "Bothell, WA",
                            Identifier = "home",
                            Latitude   = 47.7610,
                            Longitude  = 122.2056
                        }
                    }
                };

                weatherDocStore.UpdateLocations(defaultLocations);
                Logger.Info("Created Weather Locations Document");
            }
        }
Beispiel #5
0
        public override async Task <CommandResult> Execute()
        {
            await Task.CompletedTask;

            return(CommandResult.CreateSuccessResult(documentStore.GetWeatherLocations().Locations));
        }