|
|
|
@ -10,32 +10,43 @@ namespace API.Controllers
|
|
|
|
|
[Route("[controller]")]
|
|
|
|
|
public class ChampionController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<ChampionController> _logger;
|
|
|
|
|
private readonly StubData data = new StubData();
|
|
|
|
|
|
|
|
|
|
private readonly IDataManager dataManager; // Pour plus tard pour le momment c'est avec le stub
|
|
|
|
|
|
|
|
|
|
private const string Apichampion = "api/champion";
|
|
|
|
|
private readonly HttpClient _client;
|
|
|
|
|
// Pour plus tard pour le momment c'est avec le stub
|
|
|
|
|
// private readonly IDataManager dataManager;
|
|
|
|
|
|
|
|
|
|
private readonly ILogger<ChampionController> _logger;
|
|
|
|
|
|
|
|
|
|
public ChampionController(ILogger<ChampionController> logger)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* public championHttpManager(HttpClient client)
|
|
|
|
|
{
|
|
|
|
|
_client = client;
|
|
|
|
|
client.BaseAddress = new Uri("à chopper dans lauchSettings.json propriété du projet");
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
private const string Apichampion = "api/champion";
|
|
|
|
|
private readonly HttpClient _client;
|
|
|
|
|
|
|
|
|
|
public championHttpManager(HttpClient client)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
_client = client;
|
|
|
|
|
client.BaseAddress = new Uri("à chopper dans lauchSettings.json propriété du projet");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<ChampionDto>> getJson()
|
|
|
|
|
{
|
|
|
|
|
var champions = await _client.GetFromJsonAsync<IEnumerable<ChampionDto>>();
|
|
|
|
|
var reponse = await _client.GetAsync("api/champion");
|
|
|
|
|
return champions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<ChampionDto>> getJson()
|
|
|
|
|
public async void addchampion(ChampionDto champion)
|
|
|
|
|
{
|
|
|
|
|
var champions = await _client.GetFromJsonAsync<IEnumerable<ChampionDto>>();
|
|
|
|
|
var reponse = await _client.GetAsync("api/champion");
|
|
|
|
|
return champions;
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
_clientLpostAsJsonAscync<Champion>(ApiChampion, champion);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**** Méthodes GET ****/
|
|
|
|
|
[HttpGet]
|
|
|
|
@ -126,12 +137,6 @@ namespace API.Controllers
|
|
|
|
|
await data.ChampionsMgr.AddItem(championDto.ToModel()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*public async void addchampion(ChampionDto champion)
|
|
|
|
|
{
|
|
|
|
|
_clientLpostAsJsonAscync<Champion>(ApiChampion, champion);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**** Méthodes DELETE ****/
|
|
|
|
|
|
|
|
|
|
[HttpDelete("Supprimer/{id}")]
|
|
|
|
@ -149,7 +154,6 @@ namespace API.Controllers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**** Méthodes PUT ****/
|
|
|
|
|
|
|
|
|
|
[HttpPut("Modifier/{nom}")]
|
|
|
|
|