No Description

WeatherForecastController.cs 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Microsoft.AspNetCore.Mvc;
  2. using Microsoft.Extensions.Logging;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. namespace Backend.API.Controllers
  8. {
  9. [ApiController]
  10. [Route("[controller]")]
  11. public class WeatherForecastController : ControllerBase
  12. {
  13. private static readonly string[] Summaries = new[]
  14. {
  15. "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
  16. };
  17. private readonly ILogger<WeatherForecastController> _logger;
  18. public WeatherForecastController(ILogger<WeatherForecastController> logger)
  19. {
  20. _logger = logger;
  21. }
  22. [HttpGet]
  23. public IEnumerable<WeatherForecast> Get()
  24. {
  25. var rng = new Random();
  26. return Enumerable.Range(1, 5).Select(index => new WeatherForecast
  27. {
  28. Date = DateTime.Now.AddDays(index),
  29. TemperatureC = rng.Next(-20, 55),
  30. Summary = Summaries[rng.Next(Summaries.Length)]
  31. })
  32. .ToArray();
  33. }
  34. }
  35. }

Powered by TurnKey Linux.