2021-11-13 03:21:59 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Start.Shared;
|
|
|
|
|
2021-11-22 22:57:51 +00:00
|
|
|
namespace Start.Server.Controllers {
|
|
|
|
[Authorize]
|
|
|
|
[ApiController]
|
|
|
|
[Route("[controller]")]
|
|
|
|
public class WeatherForecastController : ControllerBase {
|
|
|
|
private static readonly string[] Summaries = new[]
|
|
|
|
{
|
|
|
|
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
|
|
|
};
|
2021-11-13 03:21:59 +00:00
|
|
|
|
2021-11-22 22:57:51 +00:00
|
|
|
private readonly ILogger<WeatherForecastController> _logger;
|
2021-11-13 03:21:59 +00:00
|
|
|
|
2021-11-22 22:57:51 +00:00
|
|
|
public WeatherForecastController(ILogger<WeatherForecastController> logger) {
|
|
|
|
_logger = logger;
|
|
|
|
}
|
2021-11-13 03:21:59 +00:00
|
|
|
|
2021-11-22 22:57:51 +00:00
|
|
|
[HttpGet]
|
|
|
|
public IEnumerable<WeatherForecast> Get() {
|
|
|
|
var rng = new Random();
|
|
|
|
return Enumerable.Range(1, 5).Select(index => new WeatherForecast {
|
|
|
|
Date = DateTime.Now.AddDays(index),
|
|
|
|
TemperatureC = rng.Next(-20, 55),
|
|
|
|
Summary = Summaries[rng.Next(Summaries.Length)]
|
|
|
|
})
|
|
|
|
.ToArray();
|
|
|
|
}
|
|
|
|
}
|
2021-11-13 03:21:59 +00:00
|
|
|
}
|