added put and delete

pull/28/head
Corentin R 2 years ago
parent a2d5abd371
commit b714c4c0f1

@ -137,15 +137,31 @@ namespace API_LoL.Controllers
}
// PUT api/<ChampionController>/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
[HttpPut("name")]
public async Task<IActionResult> Put(string name, ChampionDTO championDTO)
{
if(string.IsNullOrEmpty(name))
return BadRequest();
if(championDTO == null)
return UnprocessableEntity();
var list = await ChampionsManager.GetItemsByName(name, 0, 1);
if (list.Count() == 1)
{
return Ok(ChampionsManager.UpdateItem(list.First(), championDTO.ToChampion()));
}
else { return NoContent(); }
}
// DELETE api/<ChampionController>/5
[HttpDelete("{id}")]
public void Delete(int id)
[HttpDelete("name")]
public async Task<IActionResult> Delete(string name)
{
if (string.IsNullOrEmpty(name))
return BadRequest();
var list = await ChampionsManager.GetItemsByName(name, 0, 1);
if(list.Count() == 1){
return Ok(await ChampionsManager.DeleteItem(list.First()));
}else { return NoContent(); }
}
}
}

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save