expose-myit/Server/Controllers/WeatherForecastController.cs
2022-12-10 12:06:16 -07:00

36 lines
1.2 KiB
C#

using Expose.MyIT.Shared.Models.Stateless.Methods;
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
{
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;
Task<WeatherForecast[]> IWeatherForecastController.Get() => throw new NotImplementedException();
[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();
}
}