From fb75fbb6be0c3700c1537c10115e8f8fa2b8e5fc Mon Sep 17 00:00:00 2001 From: nathan boileau Date: Fri, 3 Mar 2023 15:21:33 +0100 Subject: [PATCH] =?UTF-8?q?D=C3=A9but=20liaison=20API=20->=20EF=20=20:magi?= =?UTF-8?q?c=5Fwand:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/apiLOL/Controllers/ControllerSkin.cs | 47 -------------------- Sources/apiLOL/DTO/ChampionDTO.cs | 8 ++-- Sources/apiLOL/DTO/ChampionMapper.cs | 5 ++- Sources/apiLOL/EFDataManager.cs | 20 +++++++++ Sources/apiLOL/apiLOL.csproj | 1 + 5 files changed, 29 insertions(+), 52 deletions(-) delete mode 100644 Sources/apiLOL/Controllers/ControllerSkin.cs create mode 100644 Sources/apiLOL/EFDataManager.cs diff --git a/Sources/apiLOL/Controllers/ControllerSkin.cs b/Sources/apiLOL/Controllers/ControllerSkin.cs deleted file mode 100644 index 76cfda7..0000000 --- a/Sources/apiLOL/Controllers/ControllerSkin.cs +++ /dev/null @@ -1,47 +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 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/DTO/ChampionDTO.cs b/Sources/apiLOL/DTO/ChampionDTO.cs index 023dc87..07e0ef2 100644 --- a/Sources/apiLOL/DTO/ChampionDTO.cs +++ b/Sources/apiLOL/DTO/ChampionDTO.cs @@ -3,14 +3,16 @@ public class ChampionDTO { - public ChampionDTO(string name, string bio) - { + public ChampionDTO(string name, string bio, string icon) + { Name = name; Bio = bio; - } + Icon = icon; + } public string Name { get; set; } public string Bio { get; set; } + public string Icon { get; set; } } } diff --git a/Sources/apiLOL/DTO/ChampionMapper.cs b/Sources/apiLOL/DTO/ChampionMapper.cs index b4dfb84..0c92c99 100644 --- a/Sources/apiLOL/DTO/ChampionMapper.cs +++ b/Sources/apiLOL/DTO/ChampionMapper.cs @@ -4,14 +4,15 @@ namespace apiLOL.DTO { public static class ChampionMapper { - public static ChampionDTO ToDTO(this Champion champion) => new ChampionDTO(champion.Name, champion.Bio); + public static ChampionDTO ToDTO(this Champion champion) => new ChampionDTO(champion.Name, champion.Bio, champion.Icon); public static Champion ToModel(this ChampionDTO championDTO) { Champion champ = new Champion(championDTO.Name); champ.Bio = championDTO.Bio; - return champ; + champ.Icon = championDTO.Icon; + return champ; } } diff --git a/Sources/apiLOL/EFDataManager.cs b/Sources/apiLOL/EFDataManager.cs new file mode 100644 index 0000000..28f9a32 --- /dev/null +++ b/Sources/apiLOL/EFDataManager.cs @@ -0,0 +1,20 @@ +using EFLol; +using Model; + +namespace apiLOL +{ + public class EFDataManager : IDataManager + { + // Connect to the MyDbContext class + private readonly MyDbContext _context; + + // Constructor + public EFDataManager(MyDbContext context) + { + _context = context; + } + + // Implement the interface + + } +} diff --git a/Sources/apiLOL/apiLOL.csproj b/Sources/apiLOL/apiLOL.csproj index b90f766..d8a99b3 100644 --- a/Sources/apiLOL/apiLOL.csproj +++ b/Sources/apiLOL/apiLOL.csproj @@ -20,6 +20,7 @@ +