aboutsummaryrefslogtreecommitdiff
path: root/API/Controllers/WeatherForecastController.cs
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2020-12-07 22:39:49 +0200
committertranstrike <transtrike@gmail.com>2020-12-07 22:39:49 +0200
commit648d50c387e7ee3976bd673594ed10901075475f (patch)
treeb3a0f754ca398c65afc847ea4049cad21398a0ab /API/Controllers/WeatherForecastController.cs
parentc5dc3763babe083c88dbc927f996fb1bdda80359 (diff)
downloadDevHive-648d50c387e7ee3976bd673594ed10901075475f.tar
DevHive-648d50c387e7ee3976bd673594ed10901075475f.tar.gz
DevHive-648d50c387e7ee3976bd673594ed10901075475f.zip
API folder fixed
Diffstat (limited to 'API/Controllers/WeatherForecastController.cs')
-rw-r--r--API/Controllers/WeatherForecastController.cs38
1 files changed, 38 insertions, 0 deletions
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<WeatherForecastController> _logger;
+
+ public WeatherForecastController(ILogger<WeatherForecastController> logger)
+ {
+ _logger = logger;
+ }
+
+ [HttpGet]
+ public IEnumerable<WeatherForecast> 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();
+ }
+ }
+}