aboutsummaryrefslogtreecommitdiff
path: root/PersonalApi/Controllers/WeatherForecastController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'PersonalApi/Controllers/WeatherForecastController.cs')
-rw-r--r--PersonalApi/Controllers/WeatherForecastController.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/PersonalApi/Controllers/WeatherForecastController.cs b/PersonalApi/Controllers/WeatherForecastController.cs
new file mode 100644
index 0000000..161a12a
--- /dev/null
+++ b/PersonalApi/Controllers/WeatherForecastController.cs
@@ -0,0 +1,34 @@
1using Microsoft.AspNetCore.Mvc;
2using PersonalApi.Models;
3
4namespace PersonalApi.Controllers
5{
6 [ApiController]
7 [Route("[controller]")]
8 public class WeatherForecastController : ControllerBase
9 {
10 private static readonly string[] Summaries = new[]
11 {
12 "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
13 };
14
15 private readonly ILogger<WeatherForecastController> _logger;
16
17 public WeatherForecastController(ILogger<WeatherForecastController> logger)
18 {
19 _logger = logger;
20 }
21
22 [HttpGet(Name = "GetWeatherForecast")]
23 public IEnumerable<WeatherForecast> Get()
24 {
25 return Enumerable.Range(1, 5).Select(index => new WeatherForecast
26 {
27 Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
28 TemperatureC = Random.Shared.Next(-20, 55),
29 Summary = Summaries[Random.Shared.Next(Summaries.Length)]
30 })
31 .ToArray();
32 }
33 }
34}