コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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;
        }
コード例 #4
0
 public Task <WeatherForecastStoredData> UpdateWeatherForecast(WeatherForecastStoredData weatherForecast)
 {
     WeatherForecastStorage[weatherForecast.Id] = weatherForecast;
     return(Task.FromResult(weatherForecast));
 }
コード例 #5
0
 public Task <WeatherForecastStoredData> UpdateWeatherForecast(WeatherForecastStoredData weatherForecast)
 {
     weatherForecast.Summary += _optionsSnapshot.Value.Suffix;
     WeatherForecastStorage[weatherForecast.Id] = weatherForecast;
     return(Task.FromResult(weatherForecast));
 }