/
nicteres
/
Lab1
Обзор
Документация
Войти
/
nicteres
/
Lab1
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
123
API_Lab_1/Controllers/v0/WeatherForecastController.cs
33 строки
1 KB
Matthew
Добавьте файлы проекта.
18 окт 2025, 18:03
18 окт 2025, 18:03
79e10ad
Код
Авторство
О чём код?
using Microsoft.AspNetCore.Mvc; namespace API_Lab_1.Controllers.v0 { [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(Name = "GetWeatherForecast")] public IEnumerable<WeatherForecast> 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(); } } }