34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using Expose.MyIT.Shared.Models.Stateless;
|
|
using Expose.MyIT.Shared.ViewModels;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Expose.MyIT.Server.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
[Route("api/[controller]")]
|
|
public class WeatherForecastController : ControllerBase, IWeatherForecastController<WeatherForecast[]>
|
|
{
|
|
private static readonly string[] _Summaries = new[]
|
|
{
|
|
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
|
};
|
|
|
|
private readonly ILogger<WeatherForecastController> _Logger;
|
|
|
|
public WeatherForecastController(ILogger<WeatherForecastController> logger) => _Logger = logger;
|
|
|
|
[HttpGet]
|
|
public WeatherForecast[] Get()
|
|
{
|
|
_Logger.LogDebug("I was here :)");
|
|
return Enumerable.Range(1, 5).Select(index => new WeatherForecast(new Shared.Models.WeatherForecast
|
|
{
|
|
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
|
TemperatureC = Random.Shared.Next(-20, 55),
|
|
Summary = _Summaries[Random.Shared.Next(_Summaries.Length)]
|
|
}))
|
|
.ToArray();
|
|
}
|
|
|
|
} |