From a0e30de9e49c39052804181b30e54091d1d64f58 Mon Sep 17 00:00:00 2001 From: dadalmeida1 Date: Mon, 27 Mar 2023 00:32:16 +0200 Subject: [PATCH 1/2] cleaning -v1 --- .../Controllers/RunePageController.cs | 71 ---- .../Controllers/SkillController.cs | 70 ---- .../Controllers/SkinController.cs | 80 ---- .../version1/ChampionsController.cs | 4 +- .../{ => version1}/RuneController.cs | 379 +++++++++--------- .../version1/RunePageController.cs | 219 ++++++++++ .../version2/ChampionsController.cs | 22 +- .../Controllers/version2/RuneController.cs | 190 +++++++++ .../version2/RunePageController.cs | 218 ++++++++++ .../Controllers/version2/SkillController.cs | 71 ++++ .../Controllers/version2/SkinController.cs | 81 ++++ .../API_LoL_Project/Entities.LolDatabase.db | Bin 126976 -> 126976 bytes .../Entities.LolDatabase.db-shm | Bin 32768 -> 32768 bytes .../Entities.LolDatabase.db-wal | Bin 189552 -> 0 bytes .../API_LoL_Project/LolSwaggerOptions.cs | 2 +- .../API_LoL_Project/Mapper/ChampionMapper.cs | 39 -- .../API_LoL_Project/Mapper/RuneMapper.cs | 31 -- .../API_LoL_Project/Mapper/RunePageMapper.cs | 10 - .../API_LoL_Project/Mapper/SkinMapper.cs | 13 - .../Sources/API_LoL_Project/Program.cs | 2 + .../Sources/ApiMappeur/ChampionMapper.cs | 4 +- .../Sources/ApiMappeur/RuneMapper.cs | 36 +- .../Sources/ApiMappeur/RunePageMapper.cs | 10 - .../Sources/ApiMappeur/RunePageMappeur.cs | 77 ++++ .../Sources/DTO/RunePageDTO.cs | 15 + EntityFramework_LoL/Sources/DTO/SkinDto.cs | 12 + .../Test_Api/RunePageControllerTest.cs | 12 + 27 files changed, 1131 insertions(+), 537 deletions(-) delete mode 100644 EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RunePageController.cs delete mode 100644 EntityFramework_LoL/Sources/API_LoL_Project/Controllers/SkillController.cs delete mode 100644 EntityFramework_LoL/Sources/API_LoL_Project/Controllers/SkinController.cs rename EntityFramework_LoL/Sources/API_LoL_Project/Controllers/{ => version1}/RuneController.cs (95%) create mode 100644 EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/RunePageController.cs create mode 100644 EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/RuneController.cs create mode 100644 EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/RunePageController.cs create mode 100644 EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/SkillController.cs create mode 100644 EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/SkinController.cs delete mode 100644 EntityFramework_LoL/Sources/API_LoL_Project/Mapper/ChampionMapper.cs delete mode 100644 EntityFramework_LoL/Sources/API_LoL_Project/Mapper/RuneMapper.cs delete mode 100644 EntityFramework_LoL/Sources/API_LoL_Project/Mapper/RunePageMapper.cs delete mode 100644 EntityFramework_LoL/Sources/API_LoL_Project/Mapper/SkinMapper.cs delete mode 100644 EntityFramework_LoL/Sources/ApiMappeur/RunePageMapper.cs create mode 100644 EntityFramework_LoL/Sources/ApiMappeur/RunePageMappeur.cs create mode 100644 EntityFramework_LoL/Sources/DTO/RunePageDTO.cs create mode 100644 EntityFramework_LoL/Sources/Test_Api/RunePageControllerTest.cs diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RunePageController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RunePageController.cs deleted file mode 100644 index 271d180..0000000 --- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RunePageController.cs +++ /dev/null @@ -1,71 +0,0 @@ -using DTO; -using Microsoft.AspNetCore.Mvc; - -// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 - -namespace API_LoL_Project.Controllers -{ - [Route("api/[controller]")] - [ApiController] - public class RunePageController : ControllerBase - { - /* // GET: api/ - [HttpGet] - public async Task>> Get([FromQuery] Request.PageRequest request) - { - try - { - var totalcount = await runesManager.GetNbItems(); - if (request.count + request.index > totalcount) - { - _logger.LogWarning("to many rows ask the max is {totalcount}", totalcount); - return BadRequest("to many rows ask the max is " + totalcount); - } - _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request); - - - var runes = await runesManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending)); - IEnumerable res = runes.Select(c => c.toDTO()); - if (res.Count() >= 0 || res == null) - { - _logger.LogWarning("No runes found with Id"); - return BadRequest("No runes found with Id "); - } - return Ok(res); - } - catch (Exception e) - { - _logger.LogError("About get at {e.message}", DateTime.UtcNow.ToLongTimeString()); - return BadRequest(e.Message); - - } - - - } - - // GET api//5 - [HttpGet("{id}")] - public string Get(int id) - { - return "value"; - } - - // POST api/ - [HttpPost] - public void Post([FromBody] string value) - { - } - - // PUT api//5 - [HttpPut("{id}")] - public void Put(int id, [FromBody] string value) - { - } - - // DELETE api//5 - [HttpDelete("{id}")] - public void Delete(int id) - { - }*/ - } -} diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/SkillController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/SkillController.cs deleted file mode 100644 index 042bc7e..0000000 --- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/SkillController.cs +++ /dev/null @@ -1,70 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 - -namespace API_LoL_Project.Controllers -{ - [Route("api/[controller]")] - [ApiController] - public class SkillController : ControllerBase - { - /* // GET: api/ - [HttpGet] - public async Task>> Get([FromQuery] Request.PageRequest request) - { - try - { - var totalcount = await runesManager.GetNbItems(); - if (request.count + request.index > totalcount) - { - _logger.LogWarning("to many rows ask the max is {totalcount}", totalcount); - return BadRequest("to many rows ask the max is " + totalcount); - } - _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request); - - - var runes = await runesManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending)); - IEnumerable res = runes.Select(c => c.toDTO()); - if (res.Count() >= 0 || res == null) - { - _logger.LogWarning("No runes found with Id"); - return BadRequest("No runes found with Id "); - } - return Ok(res); - } - catch (Exception e) - { - _logger.LogError("About get at {e.message}", DateTime.UtcNow.ToLongTimeString()); - return BadRequest(e.Message); - - } - - - } - - // GET api//5 - [HttpGet("{id}")] - public string Get(int id) - { - return "value"; - } - - // POST api/ - [HttpPost] - public void Post([FromBody] string value) - { - } - - // PUT api//5 - [HttpPut("{id}")] - public void Put(int id, [FromBody] string value) - { - } - - // DELETE api//5 - [HttpDelete("{id}")] - public void Delete(int id) - { - }*/ - } -} diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/SkinController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/SkinController.cs deleted file mode 100644 index 9f41870..0000000 --- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/SkinController.cs +++ /dev/null @@ -1,80 +0,0 @@ -using DTO; -using Microsoft.AspNetCore.Mvc; -using Model; - -// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 - -namespace API_LoL_Project.Controllers -{ - [Route("api/[controller]")] - [ApiController] - public class SkinController : ControllerBase - { - /* public ISkinsManager dataManager; - private readonly ILogger _logger; - public SkinController(IDataManager dataManager, ILogger logger) - { - this.dataManager = dataManager.SkinsMgr; - this._logger = logger; - } - - // GET: api/ - [HttpGet] - public async Task>> Get([FromQuery] Request.PageRequest request) - { - try - { - var totalcount = await dataManager.GetNbItems(); - if (request.count + request.index > totalcount) - { - _logger.LogWarning("to many rows ask the max is {totalcount}", totalcount); - return BadRequest("to many rows ask the max is " + totalcount); - } - _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request); - - - var runes = await dataManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending)); - IEnumerable res = runes.Select(c => c.toDTO()); - if (res.Count() >= 0 || res == null) - { - _logger.LogWarning("No runes found with Id"); - return BadRequest("No runes found with Id "); - } - return Ok(res); - } - catch (Exception e) - { - _logger.LogError("About get at {e.message}", DateTime.UtcNow.ToLongTimeString()); - return BadRequest(e.Message); - - } - - - } - - // GET api//5 - [HttpGet("{id}")] - public string Get(int id) - { - return "value"; - } - - // POST api/ - [HttpPost] - public void Post([FromBody] string value) - { - } - - // PUT api//5 - [HttpPut("{id}")] - public void Put(int id, [FromBody] string value) - { - } - - // DELETE api//5 - [HttpDelete("{id}")] - public void Delete(int id) - { - }*/ - } -} diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/ChampionsController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/ChampionsController.cs index 13fd762..86e7c1d 100644 --- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/ChampionsController.cs +++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/ChampionsController.cs @@ -327,7 +327,9 @@ namespace API_LoL_Project.Controllers.version1 } // degradation du modèle cleitn ell est dédié au cliens - [HttpGet("/count")] + // GET: api/champions/Count + + [HttpGet("/count", Name = "GetChampionCount")] public async Task> NbChampions() { var nbChampions = await dataManager.GetNbItems(); diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RuneController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/RuneController.cs similarity index 95% rename from EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RuneController.cs rename to EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/RuneController.cs index 2bef43b..c1eedff 100644 --- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RuneController.cs +++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/RuneController.cs @@ -1,189 +1,190 @@ -using DTO; -using Microsoft.AspNetCore.Mvc; -using Model; -using API_LoL_Project.Mapper; -using API_LoL_Project.Controllers.Response; -using API_LoL_Project.Middleware; - - -// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 - -namespace API_LoL_Project.Controllers -{ - [Route("api/[controller]")] - [ApiController] - - public class RuneController : ControllerBase - { - public IRunesManager dataManager; - // you should create a custom logger to be prety - private readonly ILogger _logger; - - - public RuneController(IDataManager dataManager, ILogger logger) - { - this.dataManager = dataManager.RunesMgr; - - this._logger = logger; - } - - - - /*// GET: api/ - [HttpGet] - public async Task>> GetAllRunes([FromQuery] Request.PageRequest request) - { - try - { - var totalcount = await dataManager.GetNbItems(); - if (request.count * request.index >= totalcount) - { - _logger.LogError("To many object is asked the max is {totalcount} but the request is supérior of ", totalcount); - return BadRequest("To many object is asked the max is : " + totalcount); - } - - _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(GetAllRunes), request); ; - var runes = await dataManager.GetItems(request.index, request.count, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending)); - IEnumerable res = runes.Select(c => c.toDTO()); - if (res.Count() <= 0 || res == null) - { - _logger.LogError("No runes found the total count is {totalcount} ", totalcount); - return BadRequest("No runes found : totalcount is : " + totalcount); - } - - var respList = res.Select(r => new LolResponce - ( - r, - new List - { - EndPointLink.To($"/api/[controller]/{r.Name}", "self"), - EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self"), - EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self"), - EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self"), - EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self","POST"), - EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Put)}", "self","PUT"), - } - )); - - var pageResponse = new PageResponse(respList, request.index, request.count, totalcount); - - return Ok(pageResponse); - } - catch (Exception e) - { - _logger.LogError("Somthing goes wrong caching the Rune controller : " + e.Message); - return BadRequest(e.Message); - - } - } - */ - - - // GET: api/ - /* [HttpGet] - public async Task>> Get([FromQuery] Request.PageRequest request) - { - try - { - var totalcount = await runesManager.GetNbItems(); - if (request.count + request.index > totalcount) - { - _logger.LogWarning("to many rows ask the max is {totalcount}", totalcount); - return BadRequest("to many rows ask the max is " + totalcount); - } - _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request); - - - var runes = await runesManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending)); - IEnumerable res = runes.Select(c => c.toDTO()); - if (res.Count() >= 0 || res == null) - { - _logger.LogWarning("No runes found with Id"); - return BadRequest("No runes found with Id "); - } - return Ok(res); - } - catch (Exception e) - { - _logger.LogError("About get at {e.message}", DateTime.UtcNow.ToLongTimeString()); - return BadRequest(e.Message); - - } - - - } - */ - /* - [HttpGet("{name}")] - public async Task>> GetRuneByName(string name) - { - try - { - - var rune = await dataManager - .GetItemsByName(name, 0, await dataManager.GetNbItems()); - _logger.LogInformation("Executing {Action} with name : {runeName}", nameof(GetRuneByName), name); - RuneDTO res = rune.First().toDTO(); - - if (res == null) - { - _logger.LogWarning("No runes found with {name}", name); ; - return NotFound(); - } - var links = new List - { - EndPointLink.To($"/api/[controller]/{res.Name}", "self"), - EndPointLink.To($"/api/[controller]/{res.Name}/", "self"), - EndPointLink.To($"/api/[controller]/{res.Name}/", "self") - }; - - var response = new LolResponce(res, links); - return Ok(response); - - } - catch (Exception e) - { - - _logger.LogError("Somthing goes wrong caching the Champions controller : " + e.Message); - return BadRequest(e.Message); - - } - }*/ - - /* // GET api//5 - [HttpGet("{id}")] - public string Get(int id) - { - try - { - var rune = await dataManager - .GetItemsByName(name, 0, await dataManager.GetNbItems()); - RuneDto result = champion.First().toDTO(); - return Ok(result); - } - catch (Exeption e) - { - - new HttpException(400, 'Cannot get rune :' + e.message); - } - - - }*/ - - // POST api/ - - - // PUT api//5 - [HttpPut("{id}")] - public void Put(int id, [FromBody] string value) - { - - } - - // DELETE api//5 - [HttpDelete("{id}")] - public void Delete(int id) - { - } - } -} +using DTO; +using Microsoft.AspNetCore.Mvc; +using Model; +using API_LoL_Project.Mapper; +using API_LoL_Project.Controllers.Response; +using API_LoL_Project.Middleware; + + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace API_LoL_Project.Controllers.version1 +{ + + [Route("api/v{version:apiVersion}/[controller]")] + [ApiVersion("1.0")] + [ApiController] + public class RuneController : ControllerBase + { + public IRunesManager dataManager; + // you should create a custom logger to be prety + private readonly ILogger _logger; + + + public RuneController(IDataManager dataManager, ILogger logger) + { + this.dataManager = dataManager.RunesMgr; + + _logger = logger; + } + + + + /*// GET: api/ + [HttpGet] + public async Task>> GetAllRunes([FromQuery] Request.PageRequest request) + { + try + { + var totalcount = await dataManager.GetNbItems(); + if (request.count * request.index >= totalcount) + { + _logger.LogError("To many object is asked the max is {totalcount} but the request is supérior of ", totalcount); + return BadRequest("To many object is asked the max is : " + totalcount); + } + + _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(GetAllRunes), request); ; + var runes = await dataManager.GetItems(request.index, request.count, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending)); + IEnumerable res = runes.Select(c => c.toDTO()); + if (res.Count() <= 0 || res == null) + { + _logger.LogError("No runes found the total count is {totalcount} ", totalcount); + return BadRequest("No runes found : totalcount is : " + totalcount); + } + + var respList = res.Select(r => new LolResponce + ( + r, + new List + { + EndPointLink.To($"/api/[controller]/{r.Name}", "self"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self","POST"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Put)}", "self","PUT"), + } + )); + + var pageResponse = new PageResponse(respList, request.index, request.count, totalcount); + + return Ok(pageResponse); + } + catch (Exception e) + { + _logger.LogError("Somthing goes wrong caching the Rune controller : " + e.Message); + return BadRequest(e.Message); + + } + } + */ + + + // GET: api/ + /* [HttpGet] + public async Task>> Get([FromQuery] Request.PageRequest request) + { + try + { + var totalcount = await runesManager.GetNbItems(); + if (request.count + request.index > totalcount) + { + _logger.LogWarning("to many rows ask the max is {totalcount}", totalcount); + return BadRequest("to many rows ask the max is " + totalcount); + } + _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request); + + + var runes = await runesManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending)); + IEnumerable res = runes.Select(c => c.toDTO()); + if (res.Count() >= 0 || res == null) + { + _logger.LogWarning("No runes found with Id"); + return BadRequest("No runes found with Id "); + } + return Ok(res); + } + catch (Exception e) + { + _logger.LogError("About get at {e.message}", DateTime.UtcNow.ToLongTimeString()); + return BadRequest(e.Message); + + } + + + } + */ + /* + [HttpGet("{name}")] + public async Task>> GetRuneByName(string name) + { + try + { + + var rune = await dataManager + .GetItemsByName(name, 0, await dataManager.GetNbItems()); + _logger.LogInformation("Executing {Action} with name : {runeName}", nameof(GetRuneByName), name); + RuneDTO res = rune.First().toDTO(); + + if (res == null) + { + _logger.LogWarning("No runes found with {name}", name); ; + return NotFound(); + } + var links = new List + { + EndPointLink.To($"/api/[controller]/{res.Name}", "self"), + EndPointLink.To($"/api/[controller]/{res.Name}/", "self"), + EndPointLink.To($"/api/[controller]/{res.Name}/", "self") + }; + + var response = new LolResponce(res, links); + return Ok(response); + + } + catch (Exception e) + { + + _logger.LogError("Somthing goes wrong caching the Champions controller : " + e.Message); + return BadRequest(e.Message); + + } + }*/ + + /* // GET api//5 + [HttpGet("{id}")] + public string Get(int id) + { + try + { + var rune = await dataManager + .GetItemsByName(name, 0, await dataManager.GetNbItems()); + RuneDto result = champion.First().toDTO(); + return Ok(result); + } + catch (Exeption e) + { + + new HttpException(400, 'Cannot get rune :' + e.message); + } + + + }*/ + + // POST api/ + + + // PUT api//5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + + } + + // DELETE api//5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/RunePageController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/RunePageController.cs new file mode 100644 index 0000000..da564bc --- /dev/null +++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/RunePageController.cs @@ -0,0 +1,219 @@ +using API_LoL_Project.Controllers.Response; +using API_LoL_Project.Middleware; +using DTO; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Hosting; +using Model; +using ApiMappeur; + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace API_LoL_Project.Controllers.version1 +{ + [Route("api/v{version:apiVersion}/[controller]")] + [ApiVersion("1.0")] + [ApiController] + public class RunePageController : ControllerBase + { + private IRunePagesManager dataManager; + private readonly ILogger _logger; + + public RunePageController(IDataManager dataManager, ILogger logger) + { + this.dataManager = dataManager.RunePagesMgr; + _logger = logger; + } + // GET: api/v1/ + [HttpGet] + public async Task>> Get([FromQuery] Request.PageRequest request) + { + try + { + var totalcount = await dataManager.GetNbItems(); + if (request.count * request.index >= totalcount) + { + _logger.LogError("To many object is asked the max is {totalcount} but the request is superior of ", totalcount); + return BadRequest("To many object is asked the max is : " + totalcount); + } + _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request); + + var runesP = await dataManager.GetItems(request.index, request.count == 0 ? totalcount : request.count, request.orderingPropertyName, request.descending == null ? false : (bool)request.descending); + IEnumerable res = runesP.Select(c => c.ToDto()); + if (res.Count() <= 0 || res == null) + { + _logger.LogError("No RunePage found the total count is {totalcount} ", totalcount); + return BadRequest("No RunePage found : totalcount is : " + totalcount); + } + + var respList = res.Select(r => new LolResponse + ( + r, + new List + { + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetRunePageByName)}", "self"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Post)}", "self","POST"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Put)}", "self","PUT"), + } + )); + + var pageResponse = new PageResponse(respList, request.index, request.count, totalcount); + + return Ok(pageResponse); + } + catch (Exception e) + { + _logger.LogError("Somthing goes wrong caching the RunePage controller : " + e.Message); + return BadRequest(e.Message); + + } + } + + [HttpGet("{name}")] + public async Task>>> GetRunePageByName(string name) + { + if (name == null || name == "") + { + var message = string.Format("Can not get Rune PAge without the name (is empty)"); + _logger.LogWarning(message); ; + return BadRequest(message); + } + _logger.LogInformation("Executing {Action} with name : {runePageName}", nameof(GetRunePageByName), name); + try + { + var totalcount = await dataManager.GetNbItemsByName(name); + if (totalcount <= 0) + { + _logger.LogError("No chamions found with this name {name} in the dataContext", name); ; + return NotFound("No chamions found with this name: " + name + "in the dataContext"); + } + var champion = await dataManager.GetItemsByName(name, 0, totalcount); + _logger.LogInformation($"========================= {champion} ================================================"); ; + + if (champion.Count() <= 0 || champion == null) + { + _logger.LogError($"No chamions found with {name} executing {nameof(GetRunePageByName)}"); ; + return NotFound("No chamions found with" + name); + } + IEnumerable res = champion.Select(c => c.ToDto()); + /*ChampionFullDTO res = champion.First().toFullDTO();//.First*/ + var respList = res.Select(r => new LolResponse + ( + r, + new List + { + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetRunePageByName)}", "self"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Post)}", "self","POST"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Put)}", "self","PUT"), + } + )); + + return Ok(respList); + + } + catch (Exception e) + { + + _logger.LogError("Somthing goes wrong caching the RunePage controller : " + e.Message); + return BadRequest("Somthing goes wrong caching the RunePage controller : " + e.Message); + + } + } + + + [HttpPost] + public async Task Post([FromBody] RunePageDTO runePage) + { + _logger.LogInformation("method {Action} - RUNEPAGE call with {item}", nameof(Post), runePage); + try + { + if (await dataManager.GetNbItemsByName(runePage.Name) == 0) + { + return CreatedAtAction(nameof(Get), + (await dataManager.AddItem(runePage.ToModel())).ToDto()); + } + _logger.LogWarning($"Name : {runePage.Name} is already exist"); + return BadRequest($"Name : {runePage.Name} is already exist"); + } + catch (Exception error) + { + _logger.LogError(error.Message); + return BadRequest(error.Message); + } + } + + [HttpPut("{name}")] + public async Task Put(string name, [FromBody] RunePageDTO value) + { + try + { + _logger.LogInformation("Executing {Action} with name : {championName}", nameof(Put), name); + var champion = await dataManager + .GetItemsByName(name, 0, await dataManager.GetNbItems()); + if (champion == null) + { + _logger.LogError("No chamions found with {name} in the dataBase", name); ; + return NotFound(); + } + + var savedUpdatedRunePage = await dataManager.UpdateItem(champion.First(), value.ToModel()); + if (savedUpdatedRunePage == null) + { + + _logger.LogWarning("The updated RunePage not returned {name}", name); ; + return BadRequest(); + + } + return Ok(savedUpdatedRunePage); + } + catch (Exception e) + { + _logger.LogError("Somthing goes wrong caching the RunePage controller : " + e.Message); + return BadRequest(e.Message); + } + } + + + [HttpDelete("{name}")] + public async Task Delete(string name) + { + _logger.LogInformation("method {Action} - RUNEPAGE call with {name}", nameof(Delete), name); + try + { + var dtos = await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()); + if (dtos == null) + { + _logger.LogWarning("{name} was not found", name); + return NotFound($"{name} was not found"); + } + await dataManager.DeleteItem(dtos.First()); + return NoContent(); + } + catch (Exception error) + { + _logger.LogError(error.Message); + return BadRequest(error.Message); + } + } + // GET: api//count + [HttpGet("/countRunePage", Name = "GetRunePageCount")] + public async Task> NbRunePage() + { + _logger.LogInformation("method {Action} - RUNEPAGE call", nameof(NbRunePage)); + try + { + var nbRunePage = await dataManager.GetNbItems(); + return Ok(nbRunePage); + + } + catch (Exception error) + { + _logger.LogError(error.Message); + return BadRequest(error.Message); + + } + + } + + + } +} diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/ChampionsController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/ChampionsController.cs index 0092dd4..8a5ced6 100644 --- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/ChampionsController.cs +++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/ChampionsController.cs @@ -412,13 +412,27 @@ namespace API_LoL_Project.Controllers.version2 return Ok(res); } - // degradation du modèle cleitn ell est dédié au cliens - [HttpGet("/count")] + // degradation du modèle cleitn ell est dédié au client + // GET: api/champions/Count + [HttpGet("/count", Name = "GetChampionCount")] public async Task> NbChampions() { - var nbChampions = await dataManager.GetNbItems(); - return Ok(nbChampions); + _logger.LogInformation("method {Action} - RUNEPAGE call", nameof(NbChampions)); + try + { + var nbChampions = await dataManager.GetNbItems(); + return Ok(nbChampions); + + } + catch (Exception error) + { + _logger.LogError(error.Message); + return BadRequest(error.Message); + + } + } + [HttpGet("count/class/{championClass}")] public async Task> GetChampionCountByClass(ChampionClass championClass) { diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/RuneController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/RuneController.cs new file mode 100644 index 0000000..aabbacb --- /dev/null +++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/RuneController.cs @@ -0,0 +1,190 @@ +using DTO; +using Microsoft.AspNetCore.Mvc; +using Model; +using API_LoL_Project.Mapper; +using API_LoL_Project.Controllers.Response; +using API_LoL_Project.Middleware; + + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace API_LoL_Project.Controllers.version2 +{ + + [Route("api/v{version:apiVersion}/[controller]")] + [ApiVersion("2.0")] + [ApiController] + public class RuneController : ControllerBase + { + public IRunesManager dataManager; + // you should create a custom logger to be prety + private readonly ILogger _logger; + + + public RuneController(IDataManager dataManager, ILogger logger) + { + this.dataManager = dataManager.RunesMgr; + + _logger = logger; + } + + + + /*// GET: api/ + [HttpGet] + public async Task>> GetAllRunes([FromQuery] Request.PageRequest request) + { + try + { + var totalcount = await dataManager.GetNbItems(); + if (request.count * request.index >= totalcount) + { + _logger.LogError("To many object is asked the max is {totalcount} but the request is supérior of ", totalcount); + return BadRequest("To many object is asked the max is : " + totalcount); + } + + _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(GetAllRunes), request); ; + var runes = await dataManager.GetItems(request.index, request.count, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending)); + IEnumerable res = runes.Select(c => c.toDTO()); + if (res.Count() <= 0 || res == null) + { + _logger.LogError("No runes found the total count is {totalcount} ", totalcount); + return BadRequest("No runes found : totalcount is : " + totalcount); + } + + var respList = res.Select(r => new LolResponce + ( + r, + new List + { + EndPointLink.To($"/api/[controller]/{r.Name}", "self"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self","POST"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Put)}", "self","PUT"), + } + )); + + var pageResponse = new PageResponse(respList, request.index, request.count, totalcount); + + return Ok(pageResponse); + } + catch (Exception e) + { + _logger.LogError("Somthing goes wrong caching the Rune controller : " + e.Message); + return BadRequest(e.Message); + + } + } + */ + + + // GET: api/ + /* [HttpGet] + public async Task>> Get([FromQuery] Request.PageRequest request) + { + try + { + var totalcount = await runesManager.GetNbItems(); + if (request.count + request.index > totalcount) + { + _logger.LogWarning("to many rows ask the max is {totalcount}", totalcount); + return BadRequest("to many rows ask the max is " + totalcount); + } + _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request); + + + var runes = await runesManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending)); + IEnumerable res = runes.Select(c => c.toDTO()); + if (res.Count() >= 0 || res == null) + { + _logger.LogWarning("No runes found with Id"); + return BadRequest("No runes found with Id "); + } + return Ok(res); + } + catch (Exception e) + { + _logger.LogError("About get at {e.message}", DateTime.UtcNow.ToLongTimeString()); + return BadRequest(e.Message); + + } + + + } + */ + /* + [HttpGet("{name}")] + public async Task>> GetRuneByName(string name) + { + try + { + + var rune = await dataManager + .GetItemsByName(name, 0, await dataManager.GetNbItems()); + _logger.LogInformation("Executing {Action} with name : {runeName}", nameof(GetRuneByName), name); + RuneDTO res = rune.First().toDTO(); + + if (res == null) + { + _logger.LogWarning("No runes found with {name}", name); ; + return NotFound(); + } + var links = new List + { + EndPointLink.To($"/api/[controller]/{res.Name}", "self"), + EndPointLink.To($"/api/[controller]/{res.Name}/", "self"), + EndPointLink.To($"/api/[controller]/{res.Name}/", "self") + }; + + var response = new LolResponce(res, links); + return Ok(response); + + } + catch (Exception e) + { + + _logger.LogError("Somthing goes wrong caching the Champions controller : " + e.Message); + return BadRequest(e.Message); + + } + }*/ + + /* // GET api//5 + [HttpGet("{id}")] + public string Get(int id) + { + try + { + var rune = await dataManager + .GetItemsByName(name, 0, await dataManager.GetNbItems()); + RuneDto result = champion.First().toDTO(); + return Ok(result); + } + catch (Exeption e) + { + + new HttpException(400, 'Cannot get rune :' + e.message); + } + + + }*/ + + // POST api/ + + + // PUT api//5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + + } + + // DELETE api//5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/RunePageController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/RunePageController.cs new file mode 100644 index 0000000..999438b --- /dev/null +++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/RunePageController.cs @@ -0,0 +1,218 @@ +using API_LoL_Project.Controllers.Response; +using API_LoL_Project.Middleware; +using DTO; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Hosting; +using Model; +using ApiMappeur; + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace API_LoL_Project.Controllers.version2 +{ + [Route("api/v{version:apiVersion}/[controller]")] + [ApiVersion("2.0")] + [ApiController] + public class RunePageController : ControllerBase + { + private IRunePagesManager dataManager; + private readonly ILogger _logger; + + public RunePageController(IDataManager dataManager, ILogger logger) + { + this.dataManager = dataManager.RunePagesMgr; + _logger = logger; + } + // GET: api/ + [HttpGet] + public async Task>> Get([FromQuery] Request.PageRequest request) + { + try + { + var totalcount = await dataManager.GetNbItems(); + if (request.count * request.index >= totalcount) + { + _logger.LogError("To many object is asked the max is {totalcount} but the request is superior of ", totalcount); + return BadRequest("To many object is asked the max is : " + totalcount); + } + _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request); + + var runesP = await dataManager.GetItems(request.index, request.count == 0 ? totalcount : request.count, request.orderingPropertyName, request.descending == null ? false : (bool)request.descending); + IEnumerable res = runesP.Select(c => c.ToDto()); + if (res.Count() <= 0 || res == null) + { + _logger.LogError("No RunePage found the total count is {totalcount} ", totalcount); + return BadRequest("No RunePage found : totalcount is : " + totalcount); + } + + var respList = res.Select(r => new LolResponse + ( + r, + new List + { + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetRunePageByName)}", "self"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Post)}", "self","POST"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Put)}", "self","PUT"), + } + )); + + var pageResponse = new PageResponse(respList, request.index, request.count, totalcount); + + return Ok(pageResponse); + } + catch (Exception e) + { + _logger.LogError("Somthing goes wrong caching the RunePage controller : " + e.Message); + return BadRequest(e.Message); + + } + } + // GET: api/ + [HttpGet("{name}")] + public async Task>>> GetRunePageByName(string name) + { + if (name == null || name == "") + { + var message = string.Format("Can not get Rune PAge without the name (is empty)"); + _logger.LogWarning(message); ; + return BadRequest(message); + } + _logger.LogInformation("Executing {Action} with name : {runePageName}", nameof(GetRunePageByName), name); + try + { + var totalcount = await dataManager.GetNbItemsByName(name); + if (totalcount <= 0) + { + _logger.LogError("No RunePage found with this name {name} in the dataContext", name); ; + return NotFound("No RunePage found with this name: " + name + "in the dataContext"); + } + var runeP = await dataManager.GetItemsByName(name, 0, totalcount); + _logger.LogInformation($"========================= {runeP} ================================================"); ; + + if (runeP.Count() <= 0 || runeP == null) + { + _logger.LogError($"No RunePage found with {name} executing {nameof(GetRunePageByName)}"); ; + return NotFound("No RunePage found with" + name); + } + IEnumerable res = runeP.Select(c => c.ToDto()); + var respList = res.Select(r => new LolResponse + ( + r, + new List + { + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetRunePageByName)}", "self"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Post)}", "self","POST"), + EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Put)}", "self","PUT"), + } + )); + + return Ok(respList); + + } + catch (Exception e) + { + + _logger.LogError("Somthing goes wrong caching the RunePage controller : " + e.Message); + return BadRequest("Somthing goes wrong caching the RunePage controller : " + e.Message); + + } + } + + + [HttpPost] + public async Task Post([FromBody] RunePageDTO runePage) + { + _logger.LogInformation("method {Action} - RUNEPAGE call with {item}", nameof(Post), runePage); + try + { + if (await dataManager.GetNbItemsByName(runePage.Name) == 0) + { + return CreatedAtAction(nameof(Get), + (await dataManager.AddItem(runePage.ToModel())).ToDto()); + } + _logger.LogWarning($"Name : {runePage.Name} is already exist"); + return BadRequest($"Name : {runePage.Name} is already exist"); + } + catch (Exception error) + { + _logger.LogError(error.Message); + return BadRequest(error.Message); + } + } + + [HttpPut("{name}")] + public async Task Put(string name, [FromBody] RunePageDTO value) + { + try + { + _logger.LogInformation("Executing {Action} with name : {RunePageName}", nameof(Put), name); + var runeP = await dataManager + .GetItemsByName(name, 0, await dataManager.GetNbItems()); + if (runeP == null) + { + _logger.LogError("No RunePage found with {name} in the dataBase", name); ; + return NotFound(); + } + + var savedUpdatedRunePage = await dataManager.UpdateItem(runeP.First(), value.ToModel()); + if (savedUpdatedRunePage == null) + { + + _logger.LogWarning("The updated RunePage not returned {name}", name); ; + return BadRequest(); + + } + return Ok(savedUpdatedRunePage); + } + catch (Exception e) + { + _logger.LogError("Somthing goes wrong caching the RunePage controller : " + e.Message); + return BadRequest(e.Message); + } + } + + + [HttpDelete("{name}")] + public async Task Delete(string name) + { + _logger.LogInformation("method {Action} - RUNEPAGE call with {name}", nameof(Delete), name); + try + { + var dtos = await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()); + if (dtos == null) + { + _logger.LogWarning("{name} was not found", name); + return NotFound($"{name} was not found"); + } + await dataManager.DeleteItem(dtos.First()); + return NoContent(); + } + catch (Exception error) + { + _logger.LogError(error.Message); + return BadRequest(error.Message); + } + } + // GET: api//count + [HttpGet("/countRunePage", Name = "GetRunePageCount") ] + public async Task> NbRunePage() + { + _logger.LogInformation("method {Action} - RUNEPAGE call", nameof(NbRunePage)); + try + { + var nbRunePage = await dataManager.GetNbItems(); + return Ok(nbRunePage); + + } + catch (Exception error) + { + _logger.LogError(error.Message); + return BadRequest(error.Message); + + } + + } + + + } +} diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/SkillController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/SkillController.cs new file mode 100644 index 0000000..d5bf11d --- /dev/null +++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/SkillController.cs @@ -0,0 +1,71 @@ +using Microsoft.AspNetCore.Mvc; + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace API_LoL_Project.Controllers.version2 +{ + [Route("api/v{version:apiVersion}/[controller]")] + [ApiVersion("2.0")] + [ApiController] + public class SkillController : ControllerBase + { + /* // GET: api/ + [HttpGet] + public async Task>> Get([FromQuery] Request.PageRequest request) + { + try + { + var totalcount = await runesManager.GetNbItems(); + if (request.count + request.index > totalcount) + { + _logger.LogWarning("to many rows ask the max is {totalcount}", totalcount); + return BadRequest("to many rows ask the max is " + totalcount); + } + _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request); + + + var runes = await runesManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending)); + IEnumerable res = runes.Select(c => c.toDTO()); + if (res.Count() >= 0 || res == null) + { + _logger.LogWarning("No runes found with Id"); + return BadRequest("No runes found with Id "); + } + return Ok(res); + } + catch (Exception e) + { + _logger.LogError("About get at {e.message}", DateTime.UtcNow.ToLongTimeString()); + return BadRequest(e.Message); + + } + + + } + + // GET api//5 + [HttpGet("{id}")] + public string Get(int id) + { + return "value"; + } + + // POST api/ + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT api//5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE api//5 + [HttpDelete("{id}")] + public void Delete(int id) + { + }*/ + } +} diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/SkinController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/SkinController.cs new file mode 100644 index 0000000..b4084ae --- /dev/null +++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/SkinController.cs @@ -0,0 +1,81 @@ +using DTO; +using Microsoft.AspNetCore.Mvc; +using Model; + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace API_LoL_Project.Controllers.version2 +{ + [Route("api/v{version:apiVersion}/[controller]")] + [ApiVersion("2.0")] + [ApiController] + public class SkinController : ControllerBase + { + /* public ISkinsManager dataManager; + private readonly ILogger _logger; + public SkinController(IDataManager dataManager, ILogger logger) + { + this.dataManager = dataManager.SkinsMgr; + this._logger = logger; + } + + // GET: api/ + [HttpGet] + public async Task>> Get([FromQuery] Request.PageRequest request) + { + try + { + var totalcount = await dataManager.GetNbItems(); + if (request.count + request.index > totalcount) + { + _logger.LogWarning("to many rows ask the max is {totalcount}", totalcount); + return BadRequest("to many rows ask the max is " + totalcount); + } + _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request); + + + var runes = await dataManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending)); + IEnumerable res = runes.Select(c => c.toDTO()); + if (res.Count() >= 0 || res == null) + { + _logger.LogWarning("No runes found with Id"); + return BadRequest("No runes found with Id "); + } + return Ok(res); + } + catch (Exception e) + { + _logger.LogError("About get at {e.message}", DateTime.UtcNow.ToLongTimeString()); + return BadRequest(e.Message); + + } + + + } + + // GET api//5 + [HttpGet("{id}")] + public string Get(int id) + { + return "value"; + } + + // POST api/ + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT api//5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE api//5 + [HttpDelete("{id}")] + public void Delete(int id) + { + }*/ + } +} diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Entities.LolDatabase.db b/EntityFramework_LoL/Sources/API_LoL_Project/Entities.LolDatabase.db index 912673927f4c62d7825eccd098832482b141e4b7..8aa7b42a0c37114c567723a84ed402f64e894ce5 100644 GIT binary patch delta 3033 zcma)8U5Fc16wd6-_9ii}Y2`ok`l=Y|y;S4CmZA z_dDNr?#DfHA#mhE;H0#DN02=4gKyzD*ie8dxkx@H&!38Hw@FhCic7J@%=}y?URY4G zi}92?n<^yK^jsmWE~GN)TGU4t>$Lq zGirKfK0Py+%@q=<+@Z!{)sLmq$;@IRQAnzZx%ow0yMSv`skE9+=jU>{`FjfaTt4g7 zR%Kj2n@QznGP#Vpu(*h|XEIqem(4GzdHgA#m`N7qQt{4m375CE>0RyGjqBLqX&?C& zX5kqahV!rwPLR{s;cKLMo46zl(qND;9Hg}XU-&aM3(&~Dt+Msq_H*8wbZECNXR*7ns zxoVW$z_M9t?4c#5RZ%xuuQY7Es8wl6t7&CM9g`YNvz8l_8LXx=n`-!<#Y(G1zTBxW zT3WRUC;HCL!sty0}6nl+v+TIO1b7EQyk%qnFoE3D|)Q!OgV>d~8o0;_37T{Gwd ztG1&TnTHtnuG)09j^%jqnqICryl`hV2gI>bjjrg1Zddp|%T=?v#xq!q!)(xEMXS{j z($&Ulnr-U`5v|wPvSzaq^)}Hh+y=8)se+}Q%9MCOlqXyFg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;Ryx`Z?P;w09Pae0FLShnQA%tM_-AJ&QY%Y^5h5DKmx$2ghK2lyJNxjN+&O(<<3Mx}+2qa31 zGBdM)b%c0l?6|<^URZMPy}x_?y5{=@XjGsl>3+JEw$d@SBEcC}fDHl=fB*y_009U< z00Izz00bZafnQr-k=&!Ohxq0#x$h!5)GyA82zZyuA=NCJ8xrs+a%jM=niUgp_sF3> zv&ISv$RzhF;&fC%3dli4oC*uLx@AT2&xs3k^Um0Df!+gOaozQu+!Z`ufC7IiusH-T z(0p^pZT#sZ(F1MCPSh*s}1IpaRf(-t)~XI{@Ot#dAtJLpZHifFAke0mg$5R}hvOk}Mrfcb)IKoKX_mLd1v-|nyZpIV z!SC|@Z7P~^0biSnW?aA?r?i&gr;-!bi`J3%tAM;O|7P{|A>jkAUS19HFP_LAr;%dGHjQOMnc4bN*Au2_XOh z2tWV=5P$##AOHafKmY=>1Ue)|G;j5NT~fbjzk9%Yv80MEa}0vg04tn5yP#9*6YY5g z( { options.JsonSerializerOptions.Converters.Add(new ReadOnlyDictionaryConverter()); }); + builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); @@ -58,6 +59,7 @@ if (app.Environment.IsDevelopment()) description.GroupName.ToUpperInvariant()); } }); + } app.UseHttpsRedirection(); diff --git a/EntityFramework_LoL/Sources/ApiMappeur/ChampionMapper.cs b/EntityFramework_LoL/Sources/ApiMappeur/ChampionMapper.cs index 43d10b6..a5ff45a 100644 --- a/EntityFramework_LoL/Sources/ApiMappeur/ChampionMapper.cs +++ b/EntityFramework_LoL/Sources/ApiMappeur/ChampionMapper.cs @@ -1,6 +1,4 @@ -using API_LoL_Project.Mapper; -using ApiMappeur; -using DTO; +using DTO; using Entities; using Model; diff --git a/EntityFramework_LoL/Sources/ApiMappeur/RuneMapper.cs b/EntityFramework_LoL/Sources/ApiMappeur/RuneMapper.cs index 63fb9c5..d19e07e 100644 --- a/EntityFramework_LoL/Sources/ApiMappeur/RuneMapper.cs +++ b/EntityFramework_LoL/Sources/ApiMappeur/RuneMapper.cs @@ -1,29 +1,35 @@  using DTO; using Model; +using System.Text; +using Rune = Model.Rune; - namespace API_LoL_Project.Mapper - { + +namespace ApiMappeur +{ public static class RuneMapper { public static RuneDTO ToDTO(this Rune item) { - return new RuneDTO() - { - Name = item.Name, - Family = item.Family, - }; - } + return new RuneDTO + { + Name = item.Name, + Description = item.Description, + Family = item.Family, + Icon = item.Icon, + Image = item.Image + }; + } public static Rune ToModel(this RuneDTO dto) { - /*if (dto == null) - { - *//* var message = string.Format("Champion with name = {} not found", dto.Name); - throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, message));*//* - }*/ - return new Rune(dto.Name, dto.Family); - } + /*if (dto == null) + { + *//* var message = string.Format("Champion with name = {} not found", dto.Name); + throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, message));*//* + }*/ + return new Rune(dto.Name, dto.Family, dto.Icon, dto.Image.Base64, dto.Description); + } } } diff --git a/EntityFramework_LoL/Sources/ApiMappeur/RunePageMapper.cs b/EntityFramework_LoL/Sources/ApiMappeur/RunePageMapper.cs deleted file mode 100644 index 9d334a7..0000000 --- a/EntityFramework_LoL/Sources/ApiMappeur/RunePageMapper.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Entities; -using Model; - -namespace ApiMappeur -{ - public static class RunePageMapper - { - - } -} diff --git a/EntityFramework_LoL/Sources/ApiMappeur/RunePageMappeur.cs b/EntityFramework_LoL/Sources/ApiMappeur/RunePageMappeur.cs new file mode 100644 index 0000000..7063379 --- /dev/null +++ b/EntityFramework_LoL/Sources/ApiMappeur/RunePageMappeur.cs @@ -0,0 +1,77 @@ +using DTO; +using Shared; +using Rune = Model.Rune; +using Model; + +namespace ApiMappeur +{ + /* public static class RunePageMappeur + { + public static RunePageDTO ToDto(this RunePage runePage) + { + var runePageDTO = new RunePageDTO + { + Name = runePage.Name, + Runes = new Dictionary() + }; + foreach (var runeCategory in Enum.GetValues(typeof(Category)).Cast()) + { + var rune = runePage[runeCategory]; + if (rune != null) + { + runePageDTO.Runes[runeCategory] = rune.ToDTO(); + } + } + return runePageDTO; + } + + public static RunePage ToModel(this RunePageDTO runePageDto) + { + var entity = new RunePage(runePageDto.Name); + + foreach (var kvp in runePageDto.Runes) + { + var category = kvp.Key; + var runeDTO = kvp.Value; + var rune = new Rune(runeDTO.Name, runeDTO.Family, runeDTO.Icon, runeDTO.Image.Base64, runeDTO.Description); + entity[category] = rune; + } + + return entity;} + }*/ + + + public static class RunePageMappeur + { + public static RunePageDTO ToDto(this RunePage runePage) + { + + return new RunePageDTO() + { + Name = runePage.Name, + Runes = runePage.Runes.ToDictionary(c => c.Key.ToString(), r => r.Value.ToDTO()) + }; + } + + public static RunePage ToModel(this RunePageDTO runePageDto) + { + Category category; + Dictionary runDico = runePageDto.Runes.ToDictionary( + r => (Category)Enum.Parse(typeof(Category), r.Key), + r => r.Value.ToModel() + ); + + var runePage = new RunePage(runePageDto.Name); + foreach (var rune in runePageDto.Runes) + { + if (!Enum.TryParse(rune.Key, true, out category)) + { + continue; + } + runePage[category] = rune.Value.ToModel(); + } + + return runePage; + } + } +} diff --git a/EntityFramework_LoL/Sources/DTO/RunePageDTO.cs b/EntityFramework_LoL/Sources/DTO/RunePageDTO.cs new file mode 100644 index 0000000..4be2af9 --- /dev/null +++ b/EntityFramework_LoL/Sources/DTO/RunePageDTO.cs @@ -0,0 +1,15 @@ +using Shared; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DTO +{ + public class RunePageDTO + { + public string Name { get; set; } + public Dictionary Runes { get; set; } + } +} diff --git a/EntityFramework_LoL/Sources/DTO/SkinDto.cs b/EntityFramework_LoL/Sources/DTO/SkinDto.cs index 601cf2a..b49cb28 100644 --- a/EntityFramework_LoL/Sources/DTO/SkinDto.cs +++ b/EntityFramework_LoL/Sources/DTO/SkinDto.cs @@ -16,5 +16,17 @@ namespace DTO public ImageDTO LargeImage { get; set; } + } + public class SkinFullDto + { + public string Champion { get; set; } + + public string Name { get; set; } + public string Description { get; set; } + public string Icon { get; set; } + public float Price { get; set; } + public ImageDTO LargeImage { get; set; } + + } } diff --git a/EntityFramework_LoL/Sources/Test_Api/RunePageControllerTest.cs b/EntityFramework_LoL/Sources/Test_Api/RunePageControllerTest.cs new file mode 100644 index 0000000..4ef49eb --- /dev/null +++ b/EntityFramework_LoL/Sources/Test_Api/RunePageControllerTest.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Test_Api +{ + public class RunePageControllerTest + { + } +} From 5cf4b8b1622c3c19a9a2be94f1cf3751e4ae0aec Mon Sep 17 00:00:00 2001 From: dadalmeida1 Date: Mon, 27 Mar 2023 00:37:32 +0200 Subject: [PATCH 2/2] fix ci --- .../API_LoL_Project/Controllers/version1/RuneController.cs | 1 - .../API_LoL_Project/Controllers/version2/RuneController.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/RuneController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/RuneController.cs index c1eedff..744ea0c 100644 --- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/RuneController.cs +++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version1/RuneController.cs @@ -1,7 +1,6 @@ using DTO; using Microsoft.AspNetCore.Mvc; using Model; -using API_LoL_Project.Mapper; using API_LoL_Project.Controllers.Response; using API_LoL_Project.Middleware; diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/RuneController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/RuneController.cs index aabbacb..3b01397 100644 --- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/RuneController.cs +++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/version2/RuneController.cs @@ -1,7 +1,6 @@ using DTO; using Microsoft.AspNetCore.Mvc; using Model; -using API_LoL_Project.Mapper; using API_LoL_Project.Controllers.Response; using API_LoL_Project.Middleware;