count endpoints
continuous-integration/drone/push Build is failing Details

David_next_step
David D'ALMEIDA 2 years ago
parent d416ae2183
commit 9bc670215e

@ -52,7 +52,7 @@ namespace API_LoL_Project.Controllers
if (res.Count() <= 0 || res == null) if (res.Count() <= 0 || res == null)
{ {
_logger.LogError("No chamions found the total count is {totalcount} ", totalcount); _logger.LogError("No chamions found the total count is {totalcount} ", totalcount);
return BadRequest("No chamions found : totalcount is : "+ totalcount); return BadRequest("No chamions found : totalcount is : " + totalcount);
} }
var respList = res.Select(r => new LolResponce<ChampionDTO> var respList = res.Select(r => new LolResponce<ChampionDTO>
@ -69,8 +69,8 @@ namespace API_LoL_Project.Controllers
} }
)); ));
var pageResponse = new PageResponse<ChampionDTO>(respList,request.index,request.count,totalcount); var pageResponse = new PageResponse<ChampionDTO>(respList, request.index, request.count, totalcount);
return Ok(pageResponse); return Ok(pageResponse);
} }
catch (Exception e) catch (Exception e)
@ -126,7 +126,7 @@ namespace API_LoL_Project.Controllers
_logger.LogWarning("No chamions found with {name}", name); ; _logger.LogWarning("No chamions found with {name}", name); ;
return NotFound(); return NotFound();
} }
return Ok(res.LargeImage); return Ok(res.LargeImage);
} }
@ -142,11 +142,11 @@ namespace API_LoL_Project.Controllers
[HttpGet("{name}")] [HttpGet("{name}")]
public async Task<ActionResult<LolResponce<ChampionFullDTO>>> GetChampionsByName(string name) public async Task<ActionResult<LolResponce<ChampionFullDTO>>> GetChampionsByName(string name)
{ {
_logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsByName), name); _logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsByName), name);
try try
{ {
var totalcount = await dataManager.GetNbItemsByName(name); var totalcount = await dataManager.GetNbItemsByName(name);
if ( totalcount <= 0) if (totalcount <= 0)
{ {
_logger.LogWarning("No chamions found with this name {name}", name); ; _logger.LogWarning("No chamions found with this name {name}", name); ;
return BadRequest("No chamions found with this name: " + name); return BadRequest("No chamions found with this name: " + name);
@ -154,14 +154,14 @@ namespace API_LoL_Project.Controllers
var champion = await dataManager.GetItemsByName(name, 0, totalcount); var champion = await dataManager.GetItemsByName(name, 0, totalcount);
/* IEnumerable<ChampionFullDTO> res = champion.Select(c => c.toFullDTO());//.First*/ /* IEnumerable<ChampionFullDTO> res = champion.Select(c => c.toFullDTO());//.First*/
if (champion.Count() <= 0 || champion == null ) if (champion.Count() <= 0 || champion == null)
{ {
_logger.LogWarning("No chamions found with {name}", name); ; _logger.LogWarning("No chamions found with {name}", name); ;
return NotFound("No chamions found with"+name); return NotFound("No chamions found with" + name);
} }
ChampionFullDTO res = champion.First().toFullDTO();//.First ChampionFullDTO res = champion.First().toFullDTO();//.First
var links = new List<EndPointLink> var links = new List<EndPointLink>
{ {
EndPointLink.To($"/api/[controller]/{res.Name}", "self"), EndPointLink.To($"/api/[controller]/{res.Name}", "self"),
@ -169,7 +169,7 @@ namespace API_LoL_Project.Controllers
EndPointLink.To($"/api/[controller]/{res.Name}/", "self") EndPointLink.To($"/api/[controller]/{res.Name}/", "self")
}; };
var response = new LolResponce<ChampionFullDTO>(res,links); var response = new LolResponce<ChampionFullDTO>(res, links);
return Ok(response); return Ok(response);
} }
@ -289,26 +289,26 @@ namespace API_LoL_Project.Controllers
return Ok(res); return Ok(res);
} }
/* [HttpGet("/{name}/skills")] /* [HttpGet("/{name}/skills")]
public async Task<ActionResult<SkillDto>> GetChampionsSkills(string name) public async Task<ActionResult<SkillDto>> GetChampionsSkills(string name)
{ {
_logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsSkills), name); _logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsSkills), name);
var champions = await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()); var champions = await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems());
if (champions == null) if (champions == null)
{ {
_logger.LogWarning("No chamions found with {name}", name); ; _logger.LogWarning("No chamions found with {name}", name); ;
return NotFound(); return NotFound();
} }
//skinsDTO //skinsDTO
IEnumerable<SkillDto> res = champions.First().Skills.to; IEnumerable<SkillDto> res = champions.First().Skills.to;
if (res == null) if (res == null)
{ {
_logger.LogWarning("No skins found for {name}", name); ; _logger.LogWarning("No skins found for {name}", name); ;
return NotFound(); return NotFound();
} }
return Ok(res); return Ok(res);
}*/ }*/
[HttpPost("/{name}/skills")] [HttpPost("/{name}/skills")]
public async Task<ActionResult<IEnumerable<SkinDto>>> AddChampionsSkills(string name) public async Task<ActionResult<IEnumerable<SkinDto>>> AddChampionsSkills(string name)
@ -320,15 +320,14 @@ namespace API_LoL_Project.Controllers
return Ok(res); return Ok(res);
} }
/*[HttpGet("/{name}/skins")] // degradation du modèle cleitn ell est dédié au cliens
public async Task<ActionResult<Skill> NbChampions() [HttpGet("/count")]
public async Task<ActionResult<int>> NbChampions()
{ {
var champions = await dataManager.GetItems(0, await dataManager.GetNbItems()); var nbChampions = await dataManager.GetNbItems();
IEnumerable<ChampionDTO> res = champions.Select(c => c.toDTO()); return Ok(nbChampions);
return Ok(res); }
}*/
} }
} }

Loading…
Cancel
Save