mirror of
https://github.com/farcasclaudiu/LearnCollectInst.git
synced 2026-06-22 09:01:11 +03:00
init commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using LearnCollectInst.Api.Model;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LearnCollectInst.Api.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
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(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
_logger.LogInformation("Weather forecast list started");
|
||||
|
||||
var result = Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateTime.Now.AddDays(index),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
// PLAYGROUND:
|
||||
//throw new ArgumentException("some induced error");
|
||||
|
||||
_logger.LogWarning("Weather forecast list was generated", result.Length);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user