From 2dbe282b7b080ae9f7eafd4b5a691d6fc8f9b123 Mon Sep 17 00:00:00 2001 From: nathan boileau Date: Fri, 3 Mar 2023 14:05:25 +0100 Subject: [PATCH] organisation projet --- Sources/apiLOL/ChampionPageDTO.cs | 13 ----- .../apiLOL/Controllers/ControllerChampions.cs | 3 +- Sources/apiLOL/Controllers/ControllerSkin.cs | 47 +++++++++++++++++++ Sources/apiLOL/{ => DTO}/ChampionDTO.cs | 32 ++++++------- Sources/apiLOL/{ => DTO}/ChampionMapper.cs | 36 +++++++------- Sources/apiLOL/DTO/ChampionPageDTO.cs | 13 +++++ 6 files changed, 96 insertions(+), 48 deletions(-) delete mode 100644 Sources/apiLOL/ChampionPageDTO.cs create mode 100644 Sources/apiLOL/Controllers/ControllerSkin.cs rename Sources/apiLOL/{ => DTO}/ChampionDTO.cs (73%) rename Sources/apiLOL/{ => DTO}/ChampionMapper.cs (75%) create mode 100644 Sources/apiLOL/DTO/ChampionPageDTO.cs diff --git a/Sources/apiLOL/ChampionPageDTO.cs b/Sources/apiLOL/ChampionPageDTO.cs deleted file mode 100644 index 5fff791..0000000 --- a/Sources/apiLOL/ChampionPageDTO.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace apiLOL -{ - public class ChampionPageDTO - { - public IEnumerable Data { get; set; } - - public int Index { get; set; } - - public int Count { get; set; } - - public int TotalCount { get; set; } - } -} diff --git a/Sources/apiLOL/Controllers/ControllerChampions.cs b/Sources/apiLOL/Controllers/ControllerChampions.cs index 5e129e5..337e44c 100644 --- a/Sources/apiLOL/Controllers/ControllerChampions.cs +++ b/Sources/apiLOL/Controllers/ControllerChampions.cs @@ -1,11 +1,12 @@ using System.Security.Cryptography; +using apiLOL.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 apiLOL.Controllers { - [ApiController] + [ApiController] [Route("api/v1/[controller]")] [ApiVersion("1.0")] diff --git a/Sources/apiLOL/Controllers/ControllerSkin.cs b/Sources/apiLOL/Controllers/ControllerSkin.cs new file mode 100644 index 0000000..76cfda7 --- /dev/null +++ b/Sources/apiLOL/Controllers/ControllerSkin.cs @@ -0,0 +1,47 @@ +using Microsoft.AspNetCore.Mvc; + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace apiLOL.Controllers +{ + [Route("api/[controller]")] + [ApiController] + [ApiVersion("1.0")] + public class ControllerSkin : ControllerBase + { + + + + // GET: api/ + [HttpGet] + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // 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/Sources/apiLOL/ChampionDTO.cs b/Sources/apiLOL/DTO/ChampionDTO.cs similarity index 73% rename from Sources/apiLOL/ChampionDTO.cs rename to Sources/apiLOL/DTO/ChampionDTO.cs index f015a14..023dc87 100644 --- a/Sources/apiLOL/ChampionDTO.cs +++ b/Sources/apiLOL/DTO/ChampionDTO.cs @@ -1,16 +1,16 @@ -namespace apiLOL -{ - public class ChampionDTO - { - - public ChampionDTO(string name, string bio) - { - Name = name; - Bio = bio; - } - - public string Name { get; set; } - - public string Bio { get; set; } - } -} +namespace apiLOL.DTO +{ + public class ChampionDTO + { + + public ChampionDTO(string name, string bio) + { + Name = name; + Bio = bio; + } + + public string Name { get; set; } + + public string Bio { get; set; } + } +} diff --git a/Sources/apiLOL/ChampionMapper.cs b/Sources/apiLOL/DTO/ChampionMapper.cs similarity index 75% rename from Sources/apiLOL/ChampionMapper.cs rename to Sources/apiLOL/DTO/ChampionMapper.cs index a7009ab..b4dfb84 100644 --- a/Sources/apiLOL/ChampionMapper.cs +++ b/Sources/apiLOL/DTO/ChampionMapper.cs @@ -1,18 +1,18 @@ -using Model; - -namespace apiLOL -{ - public static class ChampionMapper - { - public static ChampionDTO ToDTO(this Champion champion) => new ChampionDTO(champion.Name, champion.Bio); - - - public static Champion ToModel(this ChampionDTO championDTO) - { - Champion champ = new Champion(championDTO.Name); - champ.Bio = championDTO.Bio; - return champ; - } - - } -} +using Model; + +namespace apiLOL.DTO +{ + public static class ChampionMapper + { + public static ChampionDTO ToDTO(this Champion champion) => new ChampionDTO(champion.Name, champion.Bio); + + + public static Champion ToModel(this ChampionDTO championDTO) + { + Champion champ = new Champion(championDTO.Name); + champ.Bio = championDTO.Bio; + return champ; + } + + } +} diff --git a/Sources/apiLOL/DTO/ChampionPageDTO.cs b/Sources/apiLOL/DTO/ChampionPageDTO.cs new file mode 100644 index 0000000..4d5f71d --- /dev/null +++ b/Sources/apiLOL/DTO/ChampionPageDTO.cs @@ -0,0 +1,13 @@ +namespace apiLOL.DTO +{ + public class ChampionPageDTO + { + public IEnumerable Data { get; set; } + + public int Index { get; set; } + + public int Count { get; set; } + + public int TotalCount { get; set; } + } +}