WeatherDashboard/WeatherDashboard.Web/Controllers/HomeController.cs

35 lines
956 B
C#
Raw Normal View History

2023-02-09 02:30:14 +00:00
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using WeatherDashboard.Web.Models;
2023-02-10 03:33:02 +00:00
using WeatherDashboard.Web.Services;
2023-02-09 02:30:14 +00:00
namespace WeatherDashboard.Web.Controllers
{
public class HomeController : Controller
{
2023-02-10 03:33:02 +00:00
private readonly IForecastService forecastService;
2023-02-09 02:30:14 +00:00
2023-02-10 03:33:02 +00:00
public HomeController(IForecastService forecastService)
2023-02-09 02:30:14 +00:00
{
2023-02-10 03:33:02 +00:00
this.forecastService = forecastService;
2023-02-09 02:30:14 +00:00
}
2023-02-10 03:33:02 +00:00
public async Task<IActionResult> Index()
2023-02-09 02:30:14 +00:00
{
2023-02-10 03:33:02 +00:00
var weather = await forecastService.GetWeatherAsync();
return View(weather);
2023-02-09 02:30:14 +00:00
}
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 });
}
}
}