diff --git a/Sources/APILOL/Controllers/ChampionsController.cs b/Sources/APILOL/Controllers/ChampionsController.cs index b73d518..a64d8ca 100644 --- a/Sources/APILOL/Controllers/ChampionsController.cs +++ b/Sources/APILOL/Controllers/ChampionsController.cs @@ -68,9 +68,4 @@ namespace APILOL.Controllers return Ok(dataManager.DeleteItem(dtos.First())); } } -} - -/* -var champion = new Champion(""); -var dto = ChampionMapper.ToDto(champion); -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/Sources/APILOL/Mapper/ChampionMapper.cs b/Sources/APILOL/Mapper/ChampionMapper.cs index 883052c..b2d257d 100644 --- a/Sources/APILOL/Mapper/ChampionMapper.cs +++ b/Sources/APILOL/Mapper/ChampionMapper.cs @@ -11,12 +11,17 @@ namespace APILOL.Mapper { Name = champion.Name, Bio = champion.Bio, + Class = champion.Class, + Icon = champion.Icon, + Image = champion.Image, + Characteristics = champion.Characteristics, + Skills = champion.Skills, }; } public static Champion ToModel(this ChampionDTO champion) { - return new Champion(champion.Name); + return new Champion(champion.Name/*, champion.Class, champion.Icon, champion.Image.ToString(), champion.Bio*/); } } } diff --git a/Sources/DTO/ChampionDTO.cs b/Sources/DTO/ChampionDTO.cs index 2a8f880..12eb51f 100644 --- a/Sources/DTO/ChampionDTO.cs +++ b/Sources/DTO/ChampionDTO.cs @@ -1,8 +1,23 @@ -namespace DTO +using Model; +using System.Collections.Immutable; +using System.Collections.ObjectModel; + +namespace DTO { public class ChampionDTO { public string Name { get; set; } + public string Bio { get; set; } + + public ChampionClass Class { get; set; } + + public string Icon { get; set; } + + public LargeImage Image { get; set; } + + public ReadOnlyDictionary Characteristics { get; set; } + + public ImmutableHashSet Skills { get; set; } } } \ No newline at end of file diff --git a/Sources/DTO/DTO.csproj b/Sources/DTO/DTO.csproj index 94a926e..5c5bf12 100644 --- a/Sources/DTO/DTO.csproj +++ b/Sources/DTO/DTO.csproj @@ -16,4 +16,8 @@ + + + + diff --git a/Sources/DTO/SkillDTO.cs b/Sources/DTO/SkillDTO.cs new file mode 100644 index 0000000..0f53f56 --- /dev/null +++ b/Sources/DTO/SkillDTO.cs @@ -0,0 +1,18 @@ +using Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DTO +{ + public class SkillDTO + { + public SkillType Type { get; set; } + + public string Name { get; set; } + + public string Description { get; set; } + } +} diff --git a/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs b/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs index 342cb78..8c0db8e 100644 --- a/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs +++ b/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs @@ -22,6 +22,7 @@ namespace EntityFrameworkLOL.DBContexts protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); + // Fluent API } public SQLiteContext() diff --git a/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs b/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs index f313cdf..fac287d 100644 --- a/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs +++ b/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs @@ -18,5 +18,7 @@ namespace EntityFrameworkLOL.Entities public ImageEntity Image { get; set; } public RuneFamilyEntity Family { get; set; } + + public ICollection Pages { get; set; } } } \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/RunePageEntity.cs b/Sources/EntityFrameworkLOL/Entities/RunePageEntity.cs index e99dd61..af6d3b9 100644 --- a/Sources/EntityFrameworkLOL/Entities/RunePageEntity.cs +++ b/Sources/EntityFrameworkLOL/Entities/RunePageEntity.cs @@ -23,5 +23,7 @@ namespace EntityFrameworkLOL.Entities [NotMapped] public Dictionary Dictionary { get; set; } // Switch Dictionary to List puis faudra juste mapper la liste en dico + + public ICollection Entities { get; set; } } } \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Program.cs b/Sources/EntityFrameworkLOL/Program.cs index be3799b..07c35d6 100644 --- a/Sources/EntityFrameworkLOL/Program.cs +++ b/Sources/EntityFrameworkLOL/Program.cs @@ -8,6 +8,72 @@ class Program { static void Main(string[] args) { + using (var context = new SQLiteContext()) { + if (context.Champion.Count() > 0) + { + foreach (var c in context.Champion.ToArray()) + { + context.Champion.Remove(c); + } + } + if (context.Rune.Count() > 0) + { + foreach (var r in context.Rune.ToArray()) + { + context.Rune.Remove(r); + } + } + if (context.Skin.Count() > 0) + { + foreach (var s in context.Skin.ToArray()) + { + context.Skin.Remove(s); + } + } + if (context.Skill.Count() > 0) + { + foreach (var s in context.Skill.ToArray()) + { + context.Skill.Remove(s); + } + } + if (context.RunePage.Count() > 0) + { + foreach (var rp in context.RunePage.ToArray()) + { + context.RunePage.Remove(rp); + } + } + if (context.ChampionClass.Count() > 0) + { + foreach (var cc in context.ChampionClass.ToArray()) + { + context.ChampionClass.Remove(cc); + } + } + if (context.RuneFamily.Count() > 0) + { + foreach (var rf in context.RuneFamily.ToArray()) + { + context.RuneFamily.Remove(rf); + } + } + if (context.SkillType.Count() > 0) + { + foreach (var st in context.SkillType.ToArray()) + { + context.SkillType.Remove(st); + } + } + if (context.Image.Count() > 0) + { + foreach (var i in context.Image.ToArray()) + { + context.Image.Remove(i); + } + } + context.SaveChanges(); + } ChampionEntity akali = new ChampionEntity { Name = "Akali", Bio = "" }; ChampionEntity aatrox = new ChampionEntity { Name = "Aatrox", Bio = "" }; ChampionEntity ahri = new ChampionEntity { Name = "Ahri", Bio = "" }; @@ -19,12 +85,13 @@ class Program { // Crée des champions et les insère dans la base Console.WriteLine("Creates and inserts new Champions"); - context.Add(akali); + context.AddRange(new ChampionEntity[] { akali, aatrox, ahri, bard, alistar, akshan }); + /*context.Add(akali); context.Add(aatrox); context.Add(ahri); context.Add(bard); context.Add(alistar); - context.Add(akshan); + context.Add(akshan);*/ context.SaveChanges(); Console.WriteLine("Creates and executes a query retrieving the first Champion of the database whose name starts with an \"A\":"); var aChampion = context.Champion @@ -44,12 +111,13 @@ class Program { // Crée des Runes et les insère dans la base Console.WriteLine("Creates and inserts new Runes"); - context.Add(conqueror); + context.AddRange(new RuneEntity[] { conqueror, thriumph, alacrity, tenacity, laststand, laststand2 }); + /*context.Add(conqueror); context.Add(thriumph); context.Add(alacrity); context.Add(tenacity); context.Add(laststand); - context.Add(laststand2); + context.Add(laststand2);*/ context.SaveChanges(); Console.WriteLine("Creates and executes a query retrieving the first Runes of the database whose name starts with an \"L\":"); var lRune = context.Rune @@ -69,12 +137,13 @@ class Program { // Crée des Skins et les insère dans la base Console.WriteLine("Creates and inserts new Skins"); - context.Add(stinger); + context.AddRange(new SkinEntity[] { stinger, infernal, allStar, justicar, mecha, seaHunter }); + /*context.Add(stinger); context.Add(infernal); context.Add(allStar); context.Add(justicar); context.Add(mecha); - context.Add(seaHunter); + context.Add(seaHunter);*/ context.SaveChanges(); Console.WriteLine("Creates and executes a query retrieving the first Skins of the database whose name starts with an \"I\":"); var iSkin = context.Skin