From 5809b7fa3d118fa7283ef35aebd784682231c522 Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Wed, 11 Jan 2023 20:49:31 -0600 Subject: [PATCH] Update DI for games API controller --- .../Controllers/Api/GamesController.cs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/LANCommander/Controllers/Api/GamesController.cs b/LANCommander/Controllers/Api/GamesController.cs index 255c421..8242c13 100644 --- a/LANCommander/Controllers/Api/GamesController.cs +++ b/LANCommander/Controllers/Api/GamesController.cs @@ -1,5 +1,6 @@ using LANCommander.Data; using LANCommander.Data.Models; +using LANCommander.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -10,29 +11,24 @@ namespace LANCommander.Controllers.Api [ApiController] public class GamesController : ControllerBase { - private DatabaseContext Context; + private readonly GameService GameService; - public GamesController(DatabaseContext context) + public GamesController(GameService gameService) { - Context = context; + + GameService = gameService; } [HttpGet] public IEnumerable Get() { - using (var repo = new Repository(Context, HttpContext)) - { - return repo.Get(g => true).ToList(); - } + return GameService.Get(); } [HttpGet("{id}")] public async Task Get(Guid id) { - using (var repo = new Repository(Context, HttpContext)) - { - return await repo.Find(id); - } + return await GameService.Get(id); } } }