Fix dashboard game count

dashboard
Pat Hartl 2023-01-16 00:51:02 -06:00
parent ddc582b8e7
commit afc912a648
2 changed files with 6 additions and 8 deletions

View File

@ -2,6 +2,7 @@
using LANCommander.Data;
using LANCommander.Data.Models;
using LANCommander.Models;
using LANCommander.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
@ -12,11 +13,11 @@ namespace LANCommander.Controllers
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly DatabaseContext Context;
private readonly GameService GameService;
public HomeController(ILogger<HomeController> logger, DatabaseContext context)
public HomeController(ILogger<HomeController> logger, GameService gameService)
{
Context = context;
GameService = gameService;
_logger = logger;
}
@ -30,10 +31,7 @@ namespace LANCommander.Controllers
model.TotalAvailableFreeSpace = ByteSize.FromBytes(drives.Where(d => d.IsReady && d.Name == root).Sum(d => d.AvailableFreeSpace));
model.TotalUploadDirectorySize = ByteSize.FromBytes(new DirectoryInfo("Upload").EnumerateFiles().Sum(f => f.Length));
using (Repository<Game> repo = new Repository<Game>(Context, HttpContext))
{
model.GameCount = repo.Get(g => true).Count();
}
model.GameCount = GameService.Get().Count;
return View(model);
}

View File

@ -21,7 +21,7 @@
<div class="col-sm-4">
<div class="card">
<div class="card-body p-2 text-center">
<div class="h1 m-0">1</div>
<div class="h1 m-0">@Model.GameCount</div>
<div class="text-muted">Games</div>
</div>
</div>