diff --git a/LANCommander/Controllers/HomeController.cs b/LANCommander/Controllers/HomeController.cs index bf25e8c..eb1072a 100644 --- a/LANCommander/Controllers/HomeController.cs +++ b/LANCommander/Controllers/HomeController.cs @@ -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 _logger; - private readonly DatabaseContext Context; + private readonly GameService GameService; - public HomeController(ILogger logger, DatabaseContext context) + public HomeController(ILogger 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 repo = new Repository(Context, HttpContext)) - { - model.GameCount = repo.Get(g => true).Count(); - } + model.GameCount = GameService.Get().Count; return View(model); } diff --git a/LANCommander/Views/Home/Index.cshtml b/LANCommander/Views/Home/Index.cshtml index 622cec2..f2ad25b 100644 --- a/LANCommander/Views/Home/Index.cshtml +++ b/LANCommander/Views/Home/Index.cshtml @@ -21,7 +21,7 @@
-
1
+
@Model.GameCount
Games