WeatherForecastController.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using Microsoft.AspNetCore.Hosting.Server.Features;
  2. using Microsoft.AspNetCore.Mvc;
  3. namespace HTEX.ScreenClient.Controllers
  4. {
  5. [ApiController]
  6. [Route("[controller]")]
  7. public class WeatherForecastController : ControllerBase
  8. {
  9. private static readonly string[] Summaries = new[]
  10. {
  11. "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
  12. };
  13. private readonly ILogger<WeatherForecastController> _logger;
  14. public WeatherForecastController(ILogger<WeatherForecastController> logger)
  15. {
  16. _logger = logger;
  17. }
  18. [HttpGet]
  19. public IEnumerable<WeatherForecast> Get()
  20. {
  21. return Enumerable.Range(1, 5).Select(index => new WeatherForecast
  22. {
  23. Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
  24. TemperatureC = Random.Shared.Next(-20, 55),
  25. Summary = Summaries[Random.Shared.Next(Summaries.Length)]
  26. })
  27. .ToArray();
  28. }
  29. }
  30. }