source: Farmatiko/Controllers/WeatherForecastController.cs

Last change on this file was 30a465f, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago

Initial commit

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