From 135a9e75e180f3276cceb4e37415f84906e66016 Mon Sep 17 00:00:00 2001 From: Zach Berwaldt Date: Tue, 20 Aug 2024 19:27:34 -0400 Subject: Add project files. --- .../Controllers/WeatherForecastController.cs | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 PersonalApi/Controllers/WeatherForecastController.cs (limited to 'PersonalApi/Controllers/WeatherForecastController.cs') 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 @@ +using Microsoft.AspNetCore.Mvc; +using PersonalApi.Models; + +namespace PersonalApi.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(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} -- cgit v1.1