using System.Diagnostics; using Microsoft.AspNetCore.Mvc; using YongeStreet.Models; using YongeStreet.Services; namespace YongeStreet.Controllers; public record CityModel(string City, IList CityRoadLengthStats); public record IndexModel(IList Cities); public class HomeController : Controller { private readonly ILogger _logger; private readonly DataService _dataService; public HomeController(ILogger logger, DataService dataService) { _logger = logger; _dataService = dataService; } public IActionResult City(string city) { var cityRoadLengthStats = _dataService.GetCityRoadLengthStats(city); return View(new CityModel(city, cityRoadLengthStats)); } public IActionResult Index() { var cities = _dataService.GetCityOverview(); return View(new IndexModel(cities)); } public IActionResult Privacy() { return View(); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } }