You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

41 lines
1.2 KiB

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