You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.3 KiB
55 lines
1.3 KiB
using Api_lol.Factories;
|
|
using DTO;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Model;
|
|
using StubLib;
|
|
using System.Xml.Linq;
|
|
|
|
namespace Api_lol.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("/Champions")]
|
|
public class Champions : Controller
|
|
{
|
|
private readonly IDataManager data;
|
|
|
|
private readonly ILogger<Champions> logger;
|
|
|
|
public Champions(ILogger<Champions> logger,IDataManager manager)
|
|
{
|
|
this.logger = logger;
|
|
data = manager;
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
public async Task<IActionResult> Get()
|
|
{
|
|
var champs = (await data.ChampionsMgr.GetItems(0, await data.ChampionsMgr.GetNbItems())).Select(Model => Model.ModelToDto());
|
|
|
|
return Ok(champs);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
public IActionResult Post(DtoChampions champDTO)
|
|
{
|
|
Champion tmp = champDTO.DtoToModel();
|
|
return Ok();
|
|
}
|
|
|
|
|
|
|
|
[HttpGet]
|
|
[Route("{name}")]
|
|
public async Task<IActionResult> GetChampion(string name)
|
|
{
|
|
var champs = (await data.ChampionsMgr.GetItems(0, await data.ChampionsMgr.GetNbItems())).Where(i => i.Name == name).First();
|
|
DtoChampions result = champs.ModelToDto();
|
|
return Ok(champs);
|
|
}
|
|
|
|
}
|
|
}
|