From 9bc670215e5c5c639db7ba443eded5de2391a93d Mon Sep 17 00:00:00 2001 From: dadalmeida1 Date: Mon, 13 Mar 2023 15:59:44 +0100 Subject: [PATCH] count endpoints --- .../Controllers/ChampionsController.cs | 75 +++++++++---------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/ChampionsController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/ChampionsController.cs index 2db9d8b..3bf7f28 100644 --- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/ChampionsController.cs +++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/ChampionsController.cs @@ -52,7 +52,7 @@ namespace API_LoL_Project.Controllers if (res.Count() <= 0 || res == null) { _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 @@ -69,8 +69,8 @@ namespace API_LoL_Project.Controllers } )); - var pageResponse = new PageResponse(respList,request.index,request.count,totalcount); - + var pageResponse = new PageResponse(respList, request.index, request.count, totalcount); + return Ok(pageResponse); } catch (Exception e) @@ -126,7 +126,7 @@ namespace API_LoL_Project.Controllers _logger.LogWarning("No chamions found with {name}", name); ; return NotFound(); } - + return Ok(res.LargeImage); } @@ -142,11 +142,11 @@ namespace API_LoL_Project.Controllers [HttpGet("{name}")] public async Task>> GetChampionsByName(string name) { - _logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsByName), name); + _logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsByName), name); try { var totalcount = await dataManager.GetNbItemsByName(name); - if ( totalcount <= 0) + if (totalcount <= 0) { _logger.LogWarning("No chamions found with this name {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); /* IEnumerable 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); ; - return NotFound("No chamions found with"+name); + return NotFound("No chamions found with" + name); } ChampionFullDTO res = champion.First().toFullDTO();//.First - + var links = new List { EndPointLink.To($"/api/[controller]/{res.Name}", "self"), @@ -169,7 +169,7 @@ namespace API_LoL_Project.Controllers EndPointLink.To($"/api/[controller]/{res.Name}/", "self") }; - var response = new LolResponce(res,links); + var response = new LolResponce(res, links); return Ok(response); } @@ -289,26 +289,26 @@ namespace API_LoL_Project.Controllers return Ok(res); } - /* [HttpGet("/{name}/skills")] - public async Task> GetChampionsSkills(string name) - { - _logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsSkills), name); - var champions = await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()); - if (champions == null) - { - _logger.LogWarning("No chamions found with {name}", name); ; - return NotFound(); - } - //skinsDTO - IEnumerable res = champions.First().Skills.to; - if (res == null) - { - _logger.LogWarning("No skins found for {name}", name); ; - return NotFound(); - } - - return Ok(res); - }*/ + /* [HttpGet("/{name}/skills")] + public async Task> GetChampionsSkills(string name) + { + _logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsSkills), name); + var champions = await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()); + if (champions == null) + { + _logger.LogWarning("No chamions found with {name}", name); ; + return NotFound(); + } + //skinsDTO + IEnumerable res = champions.First().Skills.to; + if (res == null) + { + _logger.LogWarning("No skins found for {name}", name); ; + return NotFound(); + } + + return Ok(res); + }*/ [HttpPost("/{name}/skills")] public async Task>> AddChampionsSkills(string name) @@ -320,15 +320,14 @@ namespace API_LoL_Project.Controllers return Ok(res); } - /*[HttpGet("/{name}/skins")] - public async Task NbChampions() + // degradation du modèle cleitn ell est dédié au cliens + [HttpGet("/count")] + public async Task> NbChampions() { - var champions = await dataManager.GetItems(0, await dataManager.GetNbItems()); - IEnumerable res = champions.Select(c => c.toDTO()); - return Ok(res); + var nbChampions = await dataManager.GetNbItems(); + return Ok(nbChampions); + } - }*/ } - - } +