|
|
|
@ -25,7 +25,7 @@ namespace apiLOL.Controllers
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[ProducesResponseType(typeof(ChampionPageDTO), 200)]
|
|
|
|
|
public async Task<IActionResult> Get([FromQuery] int index = 0, int count = 10, string? name = "")
|
|
|
|
|
public async Task<IActionResult> GetChampions([FromQuery] int index = 0, int count = 10, string? name = "")
|
|
|
|
|
{
|
|
|
|
|
//FromQuery permet de filtrer dans la collection de champions en fonction du nom
|
|
|
|
|
// Possible de faire une classe PageRequest pour gérer les paramètres index et count
|
|
|
|
@ -49,7 +49,7 @@ namespace apiLOL.Controllers
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("{name}")]
|
|
|
|
|
[ProducesResponseType(typeof(ChampionDTO), 200)]
|
|
|
|
|
public async Task<IActionResult> GetChampion(string name)
|
|
|
|
|
public async Task<IActionResult> GetChampionByName(string name)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"methode GetChampion de ControllerChampions appelée avec le paramètre {name}");
|
|
|
|
|
try
|
|
|
|
@ -66,7 +66,7 @@ namespace apiLOL.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public async Task<IActionResult> Post(ChampionDTO champDTO)
|
|
|
|
|
public async Task<IActionResult> AddChampion(ChampionDTO champDTO)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"methode Post de ControllerChampions appelée avec le paramètre {champDTO.Name}");
|
|
|
|
|
try
|
|
|
|
@ -74,7 +74,7 @@ namespace apiLOL.Controllers
|
|
|
|
|
Champion tmp = champDTO.ToModel();
|
|
|
|
|
Champion champion = await _dataManager.AddItem(tmp);
|
|
|
|
|
ChampionDTO dtoChamp = champion.ToDTO();
|
|
|
|
|
return CreatedAtAction(nameof(GetChampion), new {name = dtoChamp.Name}, dtoChamp);
|
|
|
|
|
return CreatedAtAction(nameof(GetChampionByName), new {name = dtoChamp.Name}, dtoChamp);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -84,7 +84,7 @@ namespace apiLOL.Controllers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPut("{name}")]
|
|
|
|
|
public async Task<IActionResult> Put(string name, string bio)
|
|
|
|
|
public async Task<IActionResult> UpdateChampion(string name, string bio)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation(
|
|
|
|
|
$"methode Put de ControllerChampions appelée avec le paramètre name: {name} et bio: {bio}");
|
|
|
|
@ -103,7 +103,7 @@ namespace apiLOL.Controllers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpDelete("{name}")]
|
|
|
|
|
public async Task<IActionResult> Delete(string name)
|
|
|
|
|
public async Task<IActionResult> DeleteChampion(string name)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"methode Delete de ControllerChampions appelée avec le paramètre name: {name}");
|
|
|
|
|
|
|
|
|
|