2018-10-04 21:13:32 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2018-10-06 14:16:42 +02:00
|
|
|
|
using LaDOSE.Business.Interface;
|
2018-10-05 00:18:37 +02:00
|
|
|
|
using LaDOSE.Entity;
|
2018-10-06 13:05:38 +02:00
|
|
|
|
using LaDOSE.Entity.Context;
|
2018-10-05 01:51:23 +02:00
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2018-10-04 21:13:32 +02:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
|
|
namespace LaDOSE.Api.Controllers
|
|
|
|
|
|
{
|
2018-10-05 01:51:23 +02:00
|
|
|
|
[Authorize]
|
2018-10-04 21:13:32 +02:00
|
|
|
|
[Route("api/[controller]")]
|
2018-10-06 02:05:00 +02:00
|
|
|
|
[Produces("application/json")]
|
2018-10-05 01:51:23 +02:00
|
|
|
|
public class GameController : ControllerBase
|
2018-10-04 21:13:32 +02:00
|
|
|
|
{
|
2018-10-05 00:18:37 +02:00
|
|
|
|
|
2018-10-06 14:16:42 +02:00
|
|
|
|
private readonly IGameService _gameService;
|
2018-10-05 00:18:37 +02:00
|
|
|
|
|
2018-10-06 14:16:42 +02:00
|
|
|
|
public GameController(IGameService gameService)
|
2018-10-05 00:18:37 +02:00
|
|
|
|
{
|
2018-10-06 14:16:42 +02:00
|
|
|
|
_gameService = gameService;
|
2018-10-05 00:18:37 +02:00
|
|
|
|
}
|
2018-10-06 14:16:42 +02:00
|
|
|
|
// GET api/Game
|
2018-10-04 21:13:32 +02:00
|
|
|
|
[HttpGet]
|
2018-10-06 02:05:00 +02:00
|
|
|
|
public List<Game> Get()
|
2018-10-04 21:13:32 +02:00
|
|
|
|
{
|
2018-10-06 14:16:42 +02:00
|
|
|
|
|
|
|
|
|
|
return _gameService.GetAll().ToList();
|
|
|
|
|
|
|
2018-10-04 21:13:32 +02:00
|
|
|
|
}
|
2018-10-05 01:51:23 +02:00
|
|
|
|
|
2018-10-06 14:16:42 +02:00
|
|
|
|
// GET api/Game/5
|
2018-10-04 21:13:32 +02:00
|
|
|
|
[HttpGet("{id}")]
|
2018-10-05 01:51:23 +02:00
|
|
|
|
public Game Get(int id)
|
2018-10-04 21:13:32 +02:00
|
|
|
|
{
|
2018-10-06 14:16:42 +02:00
|
|
|
|
return _gameService.GetById(id);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPut()]
|
|
|
|
|
|
public bool Put(Game game)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _gameService.Update(game);
|
2018-10-04 21:13:32 +02:00
|
|
|
|
}
|
2018-10-06 14:16:42 +02:00
|
|
|
|
|
2018-10-04 21:13:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|