add get avec Pagination
continuous-integration/drone/push Build is failing Details

pull/1/head
Bastien OLLIER 2 years ago
parent c9066e2862
commit 8caf88020d

@ -24,21 +24,23 @@ namespace apiLOL.Controllers
// GET: api/<ControllerLol>
[HttpGet]
public async Task<IActionResult> Get([FromQuery] int index = 0, int count = 10, string name = "")
public async Task<IActionResult> Get(int index = 0, int count = 10)
{
//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
_logger.LogInformation($"methode Get de ControllerChampions appelée");
_logger.LogInformation($"Nombre de champions : {await data.ChampionsMgr.GetNbItems()}");
var champs = (await data.ChampionsMgr.GetItems(0, await data.ChampionsMgr.GetNbItems())).Select(Model => Model.ToDTO());
int nbChampions = await data.ChampionsMgr.GetNbItems();
_logger.LogInformation($"Nombre de champions : {nbChampions}");
//var champs = (await data.ChampionsMgr.GetItems(0, await data.ChampionsMgr.GetNbItems())).Select(Model => Model.ToDTO());
var champs = (await data.ChampionsMgr.GetItems(index, count)).Select(Model => Model.ToDTO());
var page = new ChampionPageDTO
{
Data = champs,
Index = index,
Count = count,
TotalCount = 100
TotalCount = nbChampions
};
return Ok(page);
}

Loading…
Cancel
Save