|
|
@ -1,14 +1,11 @@
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Model;
|
|
|
|
using Model;
|
|
|
|
using StubLib;
|
|
|
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
|
|
using static StubLib.StubData;
|
|
|
|
|
|
|
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
|
|
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
|
|
|
|
|
|
|
|
|
|
|
namespace apiLOL.Controllers
|
|
|
|
namespace apiLOL.Controllers
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[ApiController]
|
|
|
|
[ApiController]
|
|
|
|
[Route("api/v{version:apiVersion}/[controller]")]
|
|
|
|
[Route("api/v1/[controller]")]
|
|
|
|
[ApiVersion("1.0")]
|
|
|
|
[ApiVersion("1.0")]
|
|
|
|
|
|
|
|
|
|
|
|
public class ControllerChampions : Controller
|
|
|
|
public class ControllerChampions : Controller
|
|
|
@ -25,7 +22,6 @@ namespace apiLOL.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
// GET: api/<ControllerLol>
|
|
|
|
// GET: api/<ControllerLol>
|
|
|
|
[HttpGet]
|
|
|
|
[HttpGet]
|
|
|
|
[MapToApiVersion("1.0")]
|
|
|
|
|
|
|
|
public async Task<IActionResult> Get([FromQuery] int index = 0, int count = 10, string name = "")
|
|
|
|
public async Task<IActionResult> Get([FromQuery] int index = 0, int count = 10, string name = "")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//FromQuery permet de filtrer dans la collection de champions en fonction du nom
|
|
|
|
//FromQuery permet de filtrer dans la collection de champions en fonction du nom
|
|
|
@ -50,7 +46,6 @@ namespace apiLOL.Controllers
|
|
|
|
// GET api/<ControllerLol>/Charle
|
|
|
|
// GET api/<ControllerLol>/Charle
|
|
|
|
[HttpGet]
|
|
|
|
[HttpGet]
|
|
|
|
[Route("{name}")]
|
|
|
|
[Route("{name}")]
|
|
|
|
[MapToApiVersion("2.0")]
|
|
|
|
|
|
|
|
public async Task<IActionResult> GetChampion(string name)
|
|
|
|
public async Task<IActionResult> GetChampion(string name)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogInformation($"methode GetChampion de ControllerChampions appelée avec le paramètre {name}");
|
|
|
|
_logger.LogInformation($"methode GetChampion de ControllerChampions appelée avec le paramètre {name}");
|
|
|
@ -61,7 +56,6 @@ namespace apiLOL.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
// POST api/<ControllerLol>
|
|
|
|
// POST api/<ControllerLol>
|
|
|
|
[HttpPost]
|
|
|
|
[HttpPost]
|
|
|
|
[MapToApiVersion("1.0")]
|
|
|
|
|
|
|
|
public async Task<IActionResult> Post(ChampionDTO champDTO)
|
|
|
|
public async Task<IActionResult> Post(ChampionDTO champDTO)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogInformation($"methode Post de ControllerChampions appelée avec le paramètre {champDTO.Name}");
|
|
|
|
_logger.LogInformation($"methode Post de ControllerChampions appelée avec le paramètre {champDTO.Name}");
|
|
|
@ -73,7 +67,6 @@ namespace apiLOL.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
// PUT api/<ControllerLol>/5
|
|
|
|
// PUT api/<ControllerLol>/5
|
|
|
|
[HttpPut("{name}")]
|
|
|
|
[HttpPut("{name}")]
|
|
|
|
[MapToApiVersion("1.0")]
|
|
|
|
|
|
|
|
public async Task<IActionResult> Put(string name, string bio)
|
|
|
|
public async Task<IActionResult> Put(string name, string bio)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var champs = (await data.ChampionsMgr.GetItemsByName(name, 0, 1)).First();
|
|
|
|
var champs = (await data.ChampionsMgr.GetItemsByName(name, 0, 1)).First();
|
|
|
@ -83,7 +76,6 @@ namespace apiLOL.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
// DELETE api/<ControllerLol>/5
|
|
|
|
// DELETE api/<ControllerLol>/5
|
|
|
|
[HttpDelete("{name}")]
|
|
|
|
[HttpDelete("{name}")]
|
|
|
|
[MapToApiVersion("1.0")]
|
|
|
|
|
|
|
|
public async void Delete(String name)
|
|
|
|
public async void Delete(String name)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var champ = (await data.ChampionsMgr.GetItemsByName(name, 0, 1)).First();
|
|
|
|
var champ = (await data.ChampionsMgr.GetItemsByName(name, 0, 1)).First();
|
|
|
|