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