source: ChapterX.API/Controllers/WeatherForecastController.cs@ a7550ca

main
Last change on this file since a7550ca was 877c13c, checked in by kikisrbinoska <srbinoskakristina07@…>, 4 months ago

Added files

  • Property mode set to 100644
File size: 1.0 KB
Line 
1using Microsoft.AspNetCore.Mvc;
2
3namespace ChapterX.API.Controllers
4{
5 [ApiController]
6 [Route("[controller]")]
7 public class WeatherForecastController : ControllerBase
8 {
9 private static readonly string[] Summaries = new[]
10 {
11 "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12 };
13
14 private readonly ILogger<WeatherForecastController> _logger;
15
16 public WeatherForecastController(ILogger<WeatherForecastController> logger)
17 {
18 _logger = logger;
19 }
20
21 [HttpGet(Name = "GetWeatherForecast")]
22 public IEnumerable<WeatherForecast> Get()
23 {
24 return Enumerable.Range(1, 5).Select(index => new WeatherForecast
25 {
26 Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
27 TemperatureC = Random.Shared.Next(-20, 55),
28 Summary = Summaries[Random.Shared.Next(Summaries.Length)]
29 })
30 .ToArray();
31 }
32 }
33}
Note: See TracBrowser for help on using the repository browser.