From 648d50c387e7ee3976bd673594ed10901075475f Mon Sep 17 00:00:00 2001 From: transtrike Date: Mon, 7 Dec 2020 22:39:49 +0200 Subject: API folder fixed --- API/Controllers/WeatherForecastController.cs | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 API/Controllers/WeatherForecastController.cs (limited to 'API/Controllers') diff --git a/API/Controllers/WeatherForecastController.cs b/API/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..2e4b29d --- /dev/null +++ b/API/Controllers/WeatherForecastController.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace 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 _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet] + public IEnumerable 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(); + } + } +} -- cgit v1.2.3