public Task <WeatherForecastStoredData> GetWeatherForecastByDate(int locationId, string date)
        {
            WeatherForecastStoredData forecast = null;

            foreach (var weatherForecast in WeatherForecastStorage.Values)
            {
                if (weatherForecast.Location.Id == locationId &&
                    weatherForecast.Date == date)
                {
                    forecast = weatherForecast;
                }
            }

            return(Task.FromResult(forecast));
        }
        public Task <WeatherForecastStoredData> CreateWeatherForecast(LocationStoredData location, string date, string summary, double temperatureC)
        {
            var id       = GetNextId();
            var forecast = new WeatherForecastStoredData
            {
                Id           = id,
                Location     = location,
                Date         = date,
                Summary      = summary,
                TemperatureC = temperatureC
            };

            WeatherForecastStorage[id] = forecast;

            return(Task.FromResult(forecast));
        }
        private void SeedData()
        {
            if (_initialized)
            {
                return;
            }

            WeatherForecastStorage[1] = new WeatherForecastStoredData
            {
                Id       = 1,
                Location = new LocationStoredData
                {
                    Id        = 1,
                    Latitude  = 42.166679f,
                    Longitude = -83.781319f,
                    Name      = "Saline, MI" + _optionsSnapshot.Value.Suffix
                },
                Date         = "5/29/2020",
                Summary      = Summaries[new Random().Next(0, Summaries.Length)],
                TemperatureC = 20
            };

            _initialized = true;
        }
 public Task <WeatherForecastStoredData> UpdateWeatherForecast(WeatherForecastStoredData weatherForecast)
 {
     WeatherForecastStorage[weatherForecast.Id] = weatherForecast;
     return(Task.FromResult(weatherForecast));
 }
 public Task <WeatherForecastStoredData> UpdateWeatherForecast(WeatherForecastStoredData weatherForecast)
 {
     weatherForecast.Summary += _optionsSnapshot.Value.Suffix;
     WeatherForecastStorage[weatherForecast.Id] = weatherForecast;
     return(Task.FromResult(weatherForecast));
 }