Beispiel #1
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");
            }
        }