|
|
|
@ -22,84 +22,86 @@ namespace API_LoL.Controllers
|
|
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
|
{
|
|
|
|
|
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))
|
|
|
|
|
{
|
|
|
|
|
var list = await ChampionsManager.GetItemsBySkill(skill, index, size);
|
|
|
|
|
if (list.Count() != 0)
|
|
|
|
|
{
|
|
|
|
|
return Ok(list.Select(champion => champion?.ToDTO()));
|
|
|
|
|
}
|
|
|
|
|
else { return NoContent(); }
|
|
|
|
|
}
|
|
|
|
|
else if (!string.IsNullOrEmpty(characteristic))
|
|
|
|
|
{
|
|
|
|
|
var list = await ChampionsManager.GetItems(index, size);
|
|
|
|
|
if (list.Count() != 0)
|
|
|
|
|
{
|
|
|
|
|
return Ok(list.Select(champion => champion?.ToDTO()));
|
|
|
|
|
}
|
|
|
|
|
else { return NoContent(); }
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var list = await ChampionsManager.GetItems(index, size);
|
|
|
|
|
if (list.Count() != 0)
|
|
|
|
|
{
|
|
|
|
|
return Ok(list.Select(champion => champion?.ToDTO()));
|
|
|
|
|
}
|
|
|
|
|
else { return NoContent(); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//[HttpGet]
|
|
|
|
|
//public async Task<IActionResult> Get(String? name = null, 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))
|
|
|
|
|
// {
|
|
|
|
|
// var list = await ChampionsManager.GetItemsBySkill(skill, index, size);
|
|
|
|
|
// if (list.Count() != 0)
|
|
|
|
|
// {
|
|
|
|
|
// return Ok(list.Select(champion => champion?.ToDTO()));
|
|
|
|
|
// }
|
|
|
|
|
// else { return NoContent(); }
|
|
|
|
|
// }
|
|
|
|
|
// else if (!string.IsNullOrEmpty(characteristic))
|
|
|
|
|
// {
|
|
|
|
|
// var list = await ChampionsManager.GetItems(index, size);
|
|
|
|
|
// if (list.Count() != 0)
|
|
|
|
|
// {
|
|
|
|
|
// return Ok(list.Select(champion => champion?.ToDTO()));
|
|
|
|
|
// }
|
|
|
|
|
// else { return NoContent(); }
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// var list = await ChampionsManager.GetItems(index, size);
|
|
|
|
|
// if (list.Count() != 0)
|
|
|
|
|
// {
|
|
|
|
|
// return Ok(list.Select(champion => champion?.ToDTO()));
|
|
|
|
|
// }
|
|
|
|
|
// else { return NoContent(); }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// POST api/<ChampionController>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public async Task<IActionResult> Post(ChampionDTO champion)
|
|
|
|
|
{
|
|
|
|
|
if (champion == null)
|
|
|
|
|
{
|
|
|
|
|
return UnprocessableEntity();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await ChampionsManager.AddItem(champion.ToChampion());
|
|
|
|
|
return CreatedAtAction("Post", champion);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//// POST api/<ChampionController>
|
|
|
|
|
//[HttpPost]
|
|
|
|
|
//public async Task<IActionResult> Post(ChampionDTO champion)
|
|
|
|
|
//{
|
|
|
|
|
// if (champion == null)
|
|
|
|
|
// {
|
|
|
|
|
// return UnprocessableEntity();
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// await ChampionsManager.AddItem(champion.ToChampion());
|
|
|
|
|
// return CreatedAtAction("Post", champion);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
// PUT api/<ChampionController>/5
|
|
|
|
|
[HttpPut("{id}")]
|
|
|
|
|
public void Put(int id, [FromBody] string value)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
//// PUT api/<ChampionController>/5
|
|
|
|
|
//[HttpPut("{id}")]
|
|
|
|
|
//public void Put(int id, [FromBody] string value)
|
|
|
|
|
//{
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
// DELETE api/<ChampionController>/5
|
|
|
|
|
[HttpDelete("{id}")]
|
|
|
|
|
public void Delete(int id)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
//// DELETE api/<ChampionController>/5
|
|
|
|
|
//[HttpDelete("{id}")]
|
|
|
|
|
//public void Delete(int id)
|
|
|
|
|
//{
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///---------- Versioning ----------///
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[HttpGet, MapToApiVersion("2.0")]
|
|
|
|
|
public string GetThatOnlySayHello() => "Hello v2.0!";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//! FIXME : not working, mais avec la version 2.0 ca marche !
|
|
|
|
|
[HttpGet, MapToApiVersion("2.2")]
|
|
|
|
|
public string GetThatOnlySayHelloV2() => "Hello but i'm from v2.2!";
|
|
|
|
|
}
|
|
|
|
|