Update DI for games API controller
parent
21f8cbd992
commit
5809b7fa3d
|
@ -1,5 +1,6 @@
|
||||||
using LANCommander.Data;
|
using LANCommander.Data;
|
||||||
using LANCommander.Data.Models;
|
using LANCommander.Data.Models;
|
||||||
|
using LANCommander.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
@ -10,29 +11,24 @@ namespace LANCommander.Controllers.Api
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class GamesController : ControllerBase
|
public class GamesController : ControllerBase
|
||||||
{
|
{
|
||||||
private DatabaseContext Context;
|
private readonly GameService GameService;
|
||||||
|
|
||||||
public GamesController(DatabaseContext context)
|
public GamesController(GameService gameService)
|
||||||
{
|
{
|
||||||
Context = context;
|
|
||||||
|
GameService = gameService;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IEnumerable<Game> Get()
|
public IEnumerable<Game> Get()
|
||||||
{
|
{
|
||||||
using (var repo = new Repository<Game>(Context, HttpContext))
|
return GameService.Get();
|
||||||
{
|
|
||||||
return repo.Get(g => true).ToList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public async Task<Game> Get(Guid id)
|
public async Task<Game> Get(Guid id)
|
||||||
{
|
{
|
||||||
using (var repo = new Repository<Game>(Context, HttpContext))
|
return await GameService.Get(id);
|
||||||
{
|
|
||||||
return await repo.Find(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue