From 527eaedbf0f374828486b89ca0a3cfba35157162 Mon Sep 17 00:00:00 2001 From: Jolys Enzo Date: Fri, 27 Jan 2023 18:06:37 +0100 Subject: [PATCH] entity avancement --- Sources/Api-lol/Controllers/Champions.cs | 10 +++++++-- Sources/DTO/DTO.csproj | 9 +++++++- Sources/DTO/DtoChampions.cs | 5 +++-- Sources/EntityFramwork/BDDContext.cs | 21 +++++++++++++++++++ Sources/EntityFramwork/EntityFramwork.csproj | 22 ++++++++++++++++++++ Sources/LeagueOfLegends.sln | 8 ++++++- 6 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 Sources/EntityFramwork/BDDContext.cs create mode 100644 Sources/EntityFramwork/EntityFramwork.csproj diff --git a/Sources/Api-lol/Controllers/Champions.cs b/Sources/Api-lol/Controllers/Champions.cs index 991e68b..f7fd835 100644 --- a/Sources/Api-lol/Controllers/Champions.cs +++ b/Sources/Api-lol/Controllers/Champions.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Model; using StubLib; +using System.Xml.Linq; namespace Api_lol.Controllers { @@ -24,9 +25,13 @@ namespace Api_lol.Controllers [HttpGet] public IActionResult Get() { - return Ok(data.ChampionsMgr.GetItems(0,6)); + List champs = new List(); + champs = data.ChampionsMgr.GetItems(0,6); + + return Ok(champs); } + [HttpPost] public IActionResult Post(DtoChampions champHttp) { @@ -40,10 +45,11 @@ namespace Api_lol.Controllers [Route("{name}")] public IActionResult GetChampion(string name) { - foreach(var champion in champ) + foreach (var champion in data.ChampionsMgr.GetItems(0, data.ChampionsMgr.GetNbItems) { if (champion.Name == name) { + return Ok(champion); } } diff --git a/Sources/DTO/DTO.csproj b/Sources/DTO/DTO.csproj index 132c02c..a7f8dec 100644 --- a/Sources/DTO/DTO.csproj +++ b/Sources/DTO/DTO.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -6,4 +6,11 @@ enable + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/Sources/DTO/DtoChampions.cs b/Sources/DTO/DtoChampions.cs index 70f216a..d975043 100644 --- a/Sources/DTO/DtoChampions.cs +++ b/Sources/DTO/DtoChampions.cs @@ -8,11 +8,12 @@ namespace DTO { public class DtoChampions { - public string name; + public long id { get; set; } + public string name { get; set; } public DtoChampions(string name) { this.name = name; } } -} +} diff --git a/Sources/EntityFramwork/BDDContext.cs b/Sources/EntityFramwork/BDDContext.cs new file mode 100644 index 0000000..f8ef07b --- /dev/null +++ b/Sources/EntityFramwork/BDDContext.cs @@ -0,0 +1,21 @@ +using DTO; +using Microsoft.EntityFrameworkCore; + +namespace EntityFramwork +{ + public class BDDContext : DbContext + { + public BDDContext(DbContextOptions option) : base(option) { } + + + public DbSet Champions { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (!optionsBuilder.IsConfigured) + { + optionsBuilder.UseSqlite($"Data Source=BDD-APILOL.db"); ; + } + } + } +} \ No newline at end of file diff --git a/Sources/EntityFramwork/EntityFramwork.csproj b/Sources/EntityFramwork/EntityFramwork.csproj new file mode 100644 index 0000000..085c177 --- /dev/null +++ b/Sources/EntityFramwork/EntityFramwork.csproj @@ -0,0 +1,22 @@ + + + + net6.0 + enable + enable + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/Sources/LeagueOfLegends.sln b/Sources/LeagueOfLegends.sln index 9c08cdc..c78cfc3 100644 --- a/Sources/LeagueOfLegends.sln +++ b/Sources/LeagueOfLegends.sln @@ -17,7 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubLib", "StubLib\StubLib. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Api-lol", "Api-lol\Api-lol.csproj", "{F5586026-FAB8-499F-86E5-197674F775A9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DTO", "DTO\DTO.csproj", "{35D5E576-6E1A-4B2C-8FE6-C9C9B88FC452}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{35D5E576-6E1A-4B2C-8FE6-C9C9B88FC452}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFramwork", "EntityFramwork\EntityFramwork.csproj", "{2225E38B-8445-40D2-A2FE-9F90F7ACD463}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -49,6 +51,10 @@ Global {35D5E576-6E1A-4B2C-8FE6-C9C9B88FC452}.Debug|Any CPU.Build.0 = Debug|Any CPU {35D5E576-6E1A-4B2C-8FE6-C9C9B88FC452}.Release|Any CPU.ActiveCfg = Release|Any CPU {35D5E576-6E1A-4B2C-8FE6-C9C9B88FC452}.Release|Any CPU.Build.0 = Release|Any CPU + {2225E38B-8445-40D2-A2FE-9F90F7ACD463}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2225E38B-8445-40D2-A2FE-9F90F7ACD463}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2225E38B-8445-40D2-A2FE-9F90F7ACD463}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2225E38B-8445-40D2-A2FE-9F90F7ACD463}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE