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.
61 lines
1.3 KiB
61 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)
|
|
{
|
|
_logger = logger;
|
|
data = manager;
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
public IActionResult Get()
|
|
{
|
|
List<Champion> champs = new List<Champion>();
|
|
champs = data.ChampionsMgr.GetItems(0,6);
|
|
|
|
return Ok(champs);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
public IActionResult Post(DtoChampions champHttp)
|
|
{
|
|
champ.Add(champHttp.DtoToModel());
|
|
return Ok(champ);
|
|
}
|
|
|
|
|
|
|
|
[HttpGet]
|
|
[Route("{name}")]
|
|
public IActionResult GetChampion(string name)
|
|
{
|
|
foreach (var champion in data.ChampionsMgr.GetItems(0, data.ChampionsMgr.GetNbItems)
|
|
{
|
|
if (champion.Name == name)
|
|
{
|
|
|
|
return Ok(champion);
|
|
}
|
|
}
|
|
return BadRequest("Name incorrect");
|
|
}
|
|
|
|
}
|
|
}
|