using System.Diagnostics; using Microsoft.AspNetCore.Mvc; using watcher_monitoring.Models; using watcher_monitoring.Data; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; namespace watcher_monitoring.Controllers; public class HomeController : Controller { private readonly WatcherDbContext _dbContext; private readonly ILogger _logger; public HomeController(ILogger logger, WatcherDbContext dbContext) { _logger = logger; _dbContext = dbContext; } // Dashboard public async Task Index() { List servers = await _dbContext.Servers.ToListAsync(); var servers1 = new List { new { Name = "Web Server 01", IPAddress = "192.168.1.10", IsOnline = true }, new { Name = "Database Server", IPAddress = "192.168.1.20", IsOnline = true }, new { Name = "API Gateway", IPAddress = "192.168.1.30", IsOnline = true }, new { Name = "Cache Server", IPAddress = "192.168.1.40", IsOnline = false }, new { Name = "Backup Server", IPAddress = "192.168.1.50", IsOnline = true } }; ViewBag.TotalServers = servers.Count; ViewBag.OnlineServers = servers.Count(s => s.IsOnline); ViewBag.OfflineServers = servers.Count(s => !s.IsOnline); ViewBag.ServiceCount = 8; ViewBag.Servers = servers; return View(); } public IActionResult Privacy() { return View(); } public IActionResult SystemInformation() { return View(); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } }