init commit

This commit is contained in:
Claudiu Farcas
2022-10-05 09:07:14 +03:00
commit bd1826f144
19 changed files with 842 additions and 0 deletions
@@ -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;
}
}
}