WeatherForecastService.cs 792 B

12345678910111213141516171819202122232425
  1. using System;
  2. using System.Linq;
  3. using System.Threading.Tasks;
  4. namespace HyperCube.Data
  5. {
  6. public class WeatherForecastService
  7. {
  8. private static readonly string[] Summaries = new[]
  9. {
  10. "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
  11. };
  12. public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
  13. {
  14. var rng = new Random();
  15. return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
  16. {
  17. Date = startDate.AddDays(index),
  18. TemperatureC = rng.Next(-20, 55),
  19. Summary = Summaries[rng.Next(Summaries.Length)]
  20. }).ToArray());
  21. }
  22. }
  23. }