38 lines
930 B
C#
Raw Normal View History

using Microsoft.AspNetCore.Mvc;
2017-03-23 19:10:55 +01:00
using Microsoft.Extensions.HealthChecks;
using System.Threading.Tasks;
2017-03-23 19:10:55 +01:00
using WebStatus.Viewmodels;
namespace WebStatus.Controllers
{
public class HomeController : Controller
{
private readonly IHealthCheckService _healthCheckSvc;
public HomeController(IHealthCheckService checkSvc)
{
_healthCheckSvc = checkSvc;
}
public async Task<IActionResult> Index()
{
var result = await _healthCheckSvc.CheckHealthAsync();
var data = new HealthStatusViewModel(result.CheckStatus);
foreach (var checkResult in result.Results)
{
2017-03-31 12:47:56 +02:00
data.AddResult(checkResult.Key, checkResult.Value);
2017-03-23 19:10:55 +01:00
}
ViewBag.RefreshSeconds = 60;
2017-03-23 19:10:55 +01:00
return View(data);
}
public IActionResult Error()
{
return View();
}
}
}