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.2 KiB
55 lines
1.2 KiB
using Api_lol.Factories;
|
|
using DTO;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Model;
|
|
using StubLib;
|
|
|
|
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()
|
|
{
|
|
return Ok(data.ChampionsMgr.GetItems(0,6));
|
|
}
|
|
|
|
[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 champ)
|
|
{
|
|
if (champion.Name == name)
|
|
{
|
|
return Ok(champion);
|
|
}
|
|
}
|
|
return BadRequest("Name incorrect");
|
|
}
|
|
|
|
}
|
|
}
|