|
|
|
@ -4,6 +4,9 @@ using StubLib;
|
|
|
|
|
using DTO;
|
|
|
|
|
using DTO.Mapper;
|
|
|
|
|
using System.CodeDom.Compiler;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System;
|
|
|
|
|
using API_LoL.Mapper;
|
|
|
|
|
|
|
|
|
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
|
|
|
|
|
|
|
|
@ -15,29 +18,23 @@ namespace API_LoL.Controllers
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public ChampionsController(IDataManager Manager) {
|
|
|
|
|
this.ChampionsManager= Manager.ChampionsMgr;
|
|
|
|
|
this.ChampionsManager = Manager.ChampionsMgr;
|
|
|
|
|
this.SkinsManager = Manager.SkinsMgr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IChampionsManager ChampionsManager;
|
|
|
|
|
private ISkinsManager SkinsManager;
|
|
|
|
|
|
|
|
|
|
// GET api/<ChampionController>/5
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public async Task<IActionResult> Get(String? name= null,String? skill = null, String? characteristic = null,int index = 0,int size =10)
|
|
|
|
|
public async Task<IActionResult> Get(String? skill = null, String? characteristic = null,int index = 0,int size =10)
|
|
|
|
|
{
|
|
|
|
|
if (size - index > 10)
|
|
|
|
|
{
|
|
|
|
|
return BadRequest();
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(name))
|
|
|
|
|
{
|
|
|
|
|
var list = await ChampionsManager.GetItemsByName(name, index,size);
|
|
|
|
|
if (list.Count() != 0)
|
|
|
|
|
{
|
|
|
|
|
return Ok(list.Select(champion => champion?.ToDTO()));
|
|
|
|
|
}
|
|
|
|
|
else { return NoContent(); }
|
|
|
|
|
}else if(!string.IsNullOrEmpty(skill)) {
|
|
|
|
|
if(!string.IsNullOrEmpty(skill)) {
|
|
|
|
|
var list = await ChampionsManager.GetItemsBySkill(skill, index, size);
|
|
|
|
|
if (list.Count() != 0)
|
|
|
|
|
{
|
|
|
|
@ -63,6 +60,37 @@ namespace API_LoL.Controllers
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet("name")]
|
|
|
|
|
public async Task<IActionResult> GetByName(String name)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(name)) return BadRequest();
|
|
|
|
|
var list = await ChampionsManager.GetItemsByName(name, 0, 1);
|
|
|
|
|
if (list.Count() == 1)
|
|
|
|
|
{
|
|
|
|
|
return Ok(list.Select(champion => champion?.ToDTO()).First());
|
|
|
|
|
}
|
|
|
|
|
else { return NoContent(); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet("name/skills")]
|
|
|
|
|
public async Task<IActionResult> GetSkillsByName(String name)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(name)) return BadRequest();
|
|
|
|
|
var list = await ChampionsManager.GetItemsByName(name, 0, 1);
|
|
|
|
|
if (list.Count() == 1)
|
|
|
|
|
{
|
|
|
|
|
var skins = await SkinsManager.GetItemsByChampion(list.First(), 0, await SkinsManager.GetNbItemsByChampion(list.First()));
|
|
|
|
|
if(skins.Count() != 0)
|
|
|
|
|
{
|
|
|
|
|
return Ok(skins.Select(skin => skin?.ToDTO()));
|
|
|
|
|
}
|
|
|
|
|
else { return NoContent(); }
|
|
|
|
|
}
|
|
|
|
|
else { return NoContent(); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// POST api/<ChampionController>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public async Task<IActionResult> Post(ChampionDTO champion)
|
|
|
|
|