From 30542716df04c367140cd42dd6e5d1d5a1637d49 Mon Sep 17 00:00:00 2001 From: Emre Date: Sat, 18 Mar 2023 21:39:19 +0100 Subject: [PATCH 1/4] Many to Many and the dictionaries done :monkey_face: --- .../Sources/MyFlib/DataBase.db | Bin 77824 -> 131072 bytes .../Sources/MyFlib/DataSeeder.cs | 13 ++- .../Sources/MyFlib/Entities/ChampionEntity.cs | 12 +-- .../MyFlib/Entities/CharacteristicEntity.cs | 26 ++++++ .../MyFlib/Entities/DictionaryCategoryRune.cs | 25 ++++++ .../Sources/MyFlib/Entities/RuneEntity.cs | 3 +- .../Sources/MyFlib/Entities/RunePageEntity.cs | 9 ++ .../Sources/MyFlib/Entities/SkillEntity.cs | 8 +- .../Sources/MyFlib/Entities/SkinEntity.cs | 6 +- .../MyFlib/Entities/enums/CategoryEntity.cs | 2 +- .../Sources/MyFlib/LolDbContext.cs | 77 ++++++++++++++++-- .../Sources/MyFlib/Program.cs | 8 +- .../Sources/Tests/UT_EF/SkillsTest.cs | 24 +++--- 13 files changed, 169 insertions(+), 44 deletions(-) create mode 100644 src/EntityFramework_LoL/Sources/MyFlib/Entities/CharacteristicEntity.cs create mode 100644 src/EntityFramework_LoL/Sources/MyFlib/Entities/DictionaryCategoryRune.cs diff --git a/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db b/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db index 9d26f5c2b331c909c7878d162ad04f9e51a1df7e..3dcabb2bae26f5c90a464576cc24af0bdd1daae8 100644 GIT binary patch literal 131072 zcmeI5du-##dB8{f2s26e-{AHJiI@KN*y%nQvyk`OU{6=Npo9?Yow(w#jcbTMeVl=R!w93={ew z&xb;xFTqCspN8#BD8&2~{Exua|1kZXL;im$wD_Eo0s%ICH^hB9{rU9W$mfFo*l&dak0>L0vO4+7 zvFUgwlVR?%ZR2{~ymrH~9rx>aPro&_ysYuFZWt7tn&ja#OR6)=uW8S$@hewgTVG!0 zD_2&ot*xp{D{K7h)k_<_6jxW5E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}!pg$C{T0{=+BA8Av3fruRRD^XeTwWx9+9B7t(N-z>t)lfL#&tF>TuoUC3 z@DhFj??yM!d8}YNTGYuNLfYbM^z6g%)dJN&n#jhb zo@{KqJC+_9OGzU!<2$sLf~`j6so>Z|GA@n8rTy`VXkt8G^_~-GCuTW@Tb2i9IBnr9_$q~O;;VVr-j6Z4+5xqmB7Jjsv`7`Yh!vxcXc61ZE-o*gg)A)7 zpMb?#bd$n=;@kK)d^7L5@Ez`1un71*T{)=Pbfmvq8!VzP7#cKrj=Z^!ij diff --git a/src/EntityFramework_LoL/Sources/MyFlib/DataSeeder.cs b/src/EntityFramework_LoL/Sources/MyFlib/DataSeeder.cs index cc33473..cabeb12 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/DataSeeder.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/DataSeeder.cs @@ -15,7 +15,6 @@ namespace MyFlib var image1 = new LargeImageEntity { Id = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}"), Base64 = "empty" }; // Champions - ChampionEntity hecarim = new ChampionEntity { Name = "Hecarim", Class = ChampionClassEntity.Assassin, Bio = "", Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; ChampionEntity nasus = new ChampionEntity { Name = "Nasus", Class = ChampionClassEntity.Tank, Bio = "", Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; ChampionEntity ashe = new ChampionEntity { Name = "Ashe", Class = ChampionClassEntity.Marksman, Bio = "", Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; @@ -23,21 +22,19 @@ namespace MyFlib context.AddRange(hecarim, nasus, ashe); // Skins - - SkinEntity darkJhin = new SkinEntity { Name = "Dark Cosmic Jhin", ChampionForeignKey = Guid.Parse("{234F5E7F-F196-4C88-AD1C-6C392AA2E038}"), Description = "In the depths of the universe, serial killer Jhin has found a new form of power in cosmic darkness. With his galaxy mask and strange synergy with the four elements of space, he's never been deadlier.", Icon = "empty", Price = 1820, ImageId = Guid.Parse("{7cc1b02d-29a3-4493-96b7-1e3d9f3e14e2}") }; - SkinEntity kaiSaPrestige = new SkinEntity { Name = "K/DA Kai'Sa Prestige Edition", ChampionForeignKey = Guid.Parse("{15E0C4F4-4C04-4CCE-8F4D-78F37F63E63F}"), Description = "Kai'Sa, the hottest K-pop star of the moment, knows that to make a sensation, you have to be willing to do anything. With her dazzling outfit and electrifying dance moves, she'll make waves on stage and on the battlefield.", Icon = "empty", Price = 2000, ImageId = Guid.Parse("{555c9eb9-f41f-42f1-a05b-ae5d2ee7f782}") }; - SkinEntity pykeProject = new SkinEntity { Name = "PROJECT: Pyke", ChampionForeignKey = Guid.Parse("{F32FA768-A1DC-4F6A-9366-FFEC6B0D4159}"), Description = "Pyke, the ultimate android assassin, has recently been upgraded to carry out the most complex missions. With his new tools and enhanced programming, he can sneak into any security system and eliminate any target.", Icon = "empty", Price = 1350, ImageId = Guid.Parse("{6b47024c-0c1d-4066-bda8-2cb0d7c900fa}") }; + SkinEntity darkJhin = new SkinEntity { Name = "Dark Cosmic Jhin", ChampionForeignKey = hecarim.Id, Description = "In the depths of the universe, serial killer Jhin has found a new form of power in cosmic darkness. With his galaxy mask and strange synergy with the four elements of space, he's never been deadlier.", Icon = "empty", Price = 1820, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + SkinEntity kaiSaPrestige = new SkinEntity { Name = "K/DA Kai'Sa Prestige Edition", ChampionForeignKey = nasus.Id, Description = "Kai'Sa, the hottest K-pop star of the moment, knows that to make a sensation, you have to be willing to do anything. With her dazzling outfit and electrifying dance moves, she'll make waves on stage and on the battlefield.", Icon = "empty", Price = 2000, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + SkinEntity pykeProject = new SkinEntity { Name = "PROJECT: Pyke", ChampionForeignKey = ashe.Id, Description = "Pyke, the ultimate android assassin, has recently been upgraded to carry out the most complex missions. With his new tools and enhanced programming, he can sneak into any security system and eliminate any target.", Icon = "empty", Price = 1350, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; context.AddRange(darkJhin, kaiSaPrestige, pykeProject); // Skills - SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic }; - SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate }; + SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic, ChampionForeignKey = hecarim.Id }; + SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = ashe.Id }; context.AddRange(yasuoTempest, LuxFinal); // Runes - RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/ChampionEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/ChampionEntity.cs index f93cabb..6b90745 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/ChampionEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/ChampionEntity.cs @@ -1,4 +1,5 @@ -using System; +using MyFlib.Entities; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; @@ -14,7 +15,7 @@ namespace MyFlib [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid Id { get; set; } [Required] - [MaxLength(64)] + [MaxLength(64, ErrorMessage = "the champion name must not exceed 64 characters")] public string Name { get; set; } [Required] [MaxLength(255)] @@ -22,9 +23,10 @@ namespace MyFlib public string Icon { get; set; } [Required] public ChampionClassEntity Class { get; set; } - public ICollection Skills { get; set; } - public ICollection Skins { get; set; } - + public ICollection Skills { get; set; } = new List(); + public ICollection Skins { get; set; } = new List(); + public ICollection Characteristics { get; set; } + public ICollection RunePages { get; set; } = new List(); public LargeImageEntity Image { get; set; } [ForeignKey("Image")] diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/CharacteristicEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/CharacteristicEntity.cs new file mode 100644 index 0000000..cba7944 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/CharacteristicEntity.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MyFlib.Entities +{ + public class CharacteristicEntity + { + [Key] + [MaxLength(254)] + public string Name { get; set; } + + [Required] + public int Value { get; set; } + + [Required] + public Guid ChampionForeignKey { get; set; } + + [ForeignKey("ChampionForeignKey")] + public ChampionEntity Champion { get; set; } + } +} diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/DictionaryCategoryRune.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/DictionaryCategoryRune.cs new file mode 100644 index 0000000..b4b8778 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/DictionaryCategoryRune.cs @@ -0,0 +1,25 @@ +using MyFlib.Entities; +using MyFlib.Entities.enums; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MyFlib +{ + public class DictionaryCategoryRune + { + public CategoryEntity category { get; set; } + + [ForeignKey("RunePageName")] + public RunePageEntity runePage { get; set; } + public string RunePageName { get; set; } + + [ForeignKey("RuneName")] + public RuneEntity rune { get; set; } + public string RuneName { get; set; } + + } +} diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/RuneEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/RuneEntity.cs index 595b114..9b280d3 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/RuneEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/RuneEntity.cs @@ -12,7 +12,7 @@ namespace MyFlib public class RuneEntity { [Key] - [MaxLength(64)] + [MaxLength(64, ErrorMessage = "the Rune name must not exceed 64 characters")] public string Name { get; set; } [Required] @@ -20,6 +20,7 @@ namespace MyFlib public string Description { get; set; } [Required] public RuneFamilyEntity Family { get; set; } + public ICollection DictionaryCategoryRunes { get; set; } public LargeImageEntity Image { get; set; } [ForeignKey("Image")] diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/RunePageEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/RunePageEntity.cs index d23e7a0..66f3c7f 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/RunePageEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/RunePageEntity.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -8,5 +9,13 @@ namespace MyFlib.Entities { public class RunePageEntity { + [Key] + [MaxLength(64, ErrorMessage = "the RunePage name must not exceed 64 characters")] + public string Name { get; set; } + + public ICollection Champions { get; set; } + public ICollection DictionaryCategoryRunes { get; set; } + + } } diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkillEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkillEntity.cs index fb27e82..b6349d5 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkillEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkillEntity.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,7 +11,7 @@ namespace MyFlib public class SkillEntity { [Key] - [MaxLength(64)] + [MaxLength(64, ErrorMessage = "the Skill name must not exceed 64 characters")] public string Name { get; set; } [Required] @@ -20,5 +21,10 @@ namespace MyFlib [Required] public SkillTypeEntity Type { get; set; } + [Required] + [ForeignKey("ChampionForeignKey")] + public ChampionEntity Champion { get; set; } + public Guid ChampionForeignKey { get; set; } + } } diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkinEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkinEntity.cs index 4aba605..a2b8518 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkinEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkinEntity.cs @@ -11,15 +11,17 @@ namespace MyFlib public class SkinEntity { [Key] - [MaxLength(256)] + [MaxLength(254, ErrorMessage = "the Skin name must not exceed 254 characters")] public string Name { get; set; } [Required] - [MaxLength(500)] + [MaxLength(1000)] public string Description { get; set; } [Required] public string Icon { get; set; } [Required] public float Price { get; set; } + [Required] + [ForeignKey("ChampionForeignKey")] public ChampionEntity Champion { get; set; } public Guid ChampionForeignKey { get; set; } public LargeImageEntity Image { get; set; } diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/CategoryEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/CategoryEntity.cs index fd59784..83863f7 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/CategoryEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/CategoryEntity.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace MyFlib.Entities.enums { - enum CategoryEntity + public enum CategoryEntity { Major, Minor1, diff --git a/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs index 9acfecc..845f521 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore; +using MyFlib.Entities; using MyFlib.Entities.enums; using System; using System.Collections.Generic; @@ -15,6 +16,9 @@ namespace MyFlib public DbSet Skills { get; set; } public DbSet Skins { get; set; } public DbSet Runes { get; set; } + public DbSet CategoryRunes { get; set; } + public DbSet RunePages { get; set; } + public LolDbContext() { } @@ -38,9 +42,9 @@ namespace MyFlib //ChampionEntity modelBuilder.Entity().HasKey(e => e.Id); - - modelBuilder.Entity().Property(e => e.Id).ValueGeneratedOnAdd(); + modelBuilder.Entity().HasMany(champion => champion.RunePages).WithMany(runePage => runePage.Champions); + ChampionEntity Akali = new ChampionEntity { Id = Guid.Parse("{4422C524-B2CB-43EF-8263-990C3CEA7CAE}"), Name = "Akali", Class = ChampionClassEntity.Assassin, Bio = "", Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; ChampionEntity Aatrox = new ChampionEntity { Id = Guid.Parse("{A4F84D92-C20F-4F2D-B3F9-CA00EF556E72}"), Name = "Aatrox", Class = ChampionClassEntity.Fighter, Bio = "", Icon = "", ImageId = Guid.Parse("{9f9086f5-5cc5-47b5-af9b-a935f4e9b89c}") }; ChampionEntity Ahri = new ChampionEntity { Id = Guid.Parse("{AE5FE535-F041-445E-B570-28B75BC78CB9}"), Name = "Ahri", Class = ChampionClassEntity.Mage, Bio = "", Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; @@ -52,9 +56,14 @@ namespace MyFlib modelBuilder.Entity().HasData(Akali, Aatrox, Ahri, Akshan, Bard, Alistar); //SkillEntity + modelBuilder.Entity() + .HasOne(m => m.Champion) + .WithMany(a => a.Skills) + .HasForeignKey("ChampionForeignKey"); + modelBuilder.Entity().HasData( - new { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Basic }, - new { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate } + new { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Basic, ChampionForeignKey = Guid.Parse("{4422C524-B2CB-43EF-8263-990C3CEA7CAE}") }, + new { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = Guid.Parse("{3708dcfd-02a1-491e-b4f7-e75bf274cf23}") } ); //SkinEntity @@ -69,9 +78,63 @@ namespace MyFlib ); //RuneEntity - modelBuilder.Entity().HasData( - new RuneEntity { Name = "Hextech Flashtraption ", Description = "While Flash is on cooldown, it is replaced by Hexflash.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }, - new RuneEntity { Name = "Manaflow Band ", Description = "Hitting enemy champions with a spell grants 25 maximum mana, up to 250 mana.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{9f9086f5-5cc5-47b5-af9b-a935f4e9b89c}") } + RuneEntity runeHextech = new RuneEntity { Name = "Hextech Flashtraption ", Description = "While Flash is on cooldown, it is replaced by Hexflash.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity runeManaflow = new RuneEntity { Name = "Manaflow Band ", Description = "Hitting enemy champions with a spell grants 25 maximum mana, up to 250 mana.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{9f9086f5-5cc5-47b5-af9b-a935f4e9b89c}") }; + modelBuilder.Entity().HasData(runeHextech, runeManaflow); + + //RunePageEntity + RunePageEntity page1 = new RunePageEntity { Name = "Page 1" }; + RunePageEntity page2 = new RunePageEntity { Name = "Page 2" }; + + modelBuilder.Entity().HasData(page1, page2); + + //DictionaryCategoryRune + modelBuilder.Entity().HasKey(dictionary => new { dictionary.RunePageName, dictionary.RuneName }); + modelBuilder.Entity().HasData( + new DictionaryCategoryRune { category = CategoryEntity.Major, RuneName = runeHextech.Name, RunePageName = page1.Name }, + new DictionaryCategoryRune { category = CategoryEntity.Minor1, RuneName = runeManaflow.Name, RunePageName = page1.Name }, + new DictionaryCategoryRune { category = CategoryEntity.OtherMinor1, RuneName = runeManaflow.Name, RunePageName = page2.Name }, + new DictionaryCategoryRune { category = CategoryEntity.OtherMinor2, RuneName = runeHextech.Name, RunePageName = page2.Name } + ); + + //CharacteristicEntity + modelBuilder.Entity().HasKey(c => new { c.Name, c.ChampionForeignKey }); + + modelBuilder.Entity().HasData( + new CharacteristicEntity { Name = "Attack Damage", Value = 58, ChampionForeignKey = Ahri.Id }, + new CharacteristicEntity { Name = "Ability Power", Value = 92, ChampionForeignKey = Ahri.Id }, + new CharacteristicEntity { Name = "Attack Speed", Value = 6, ChampionForeignKey = Ahri.Id }, + new CharacteristicEntity { Name = "Health", Value = 526, ChampionForeignKey = Ahri.Id }, + new CharacteristicEntity { Name = "Mana", Value = 418, ChampionForeignKey = Ahri.Id }, + + new CharacteristicEntity { Name = "Attack Damage", Value = 68, ChampionForeignKey = Akshan.Id }, + new CharacteristicEntity { Name = "Ability Power", Value = 0, ChampionForeignKey = Akshan.Id }, + new CharacteristicEntity { Name = "Attack Speed", Value = 1, ChampionForeignKey = Akshan.Id }, + new CharacteristicEntity { Name = "Health", Value = 570, ChampionForeignKey = Akshan.Id }, + new CharacteristicEntity { Name = "Mana", Value = 350, ChampionForeignKey = Akshan.Id }, + + new CharacteristicEntity { Name = "Attack Damage", Value = 70, ChampionForeignKey = Aatrox.Id }, + new CharacteristicEntity { Name = "Ability Power", Value = 0, ChampionForeignKey = Aatrox.Id }, + new CharacteristicEntity { Name = "Attack Speed", Value = 1, ChampionForeignKey = Aatrox.Id }, + new CharacteristicEntity { Name = "Health", Value = 580, ChampionForeignKey = Aatrox.Id }, + new CharacteristicEntity { Name = "Mana", Value = 0, ChampionForeignKey = Aatrox.Id }, + + new CharacteristicEntity { Name = "Attack Damage", Value = 56, ChampionForeignKey = Akali.Id }, + new CharacteristicEntity { Name = "Ability Power", Value = 0, ChampionForeignKey = Akali.Id }, + new CharacteristicEntity { Name = "Attack Speed", Value = 1, ChampionForeignKey = Akali.Id }, + new CharacteristicEntity { Name = "Health", Value = 575, ChampionForeignKey = Akali.Id }, + new CharacteristicEntity { Name = "Mana", Value = 200, ChampionForeignKey = Akali.Id }, + + new CharacteristicEntity { Name = "Attack Damage", Value = 63, ChampionForeignKey = Alistar.Id }, + new CharacteristicEntity { Name = "Ability Power", Value = 0, ChampionForeignKey = Alistar.Id }, + new CharacteristicEntity { Name = "Attack Speed", Value = 2, ChampionForeignKey = Alistar.Id }, + new CharacteristicEntity { Name = "Health", Value = 573, ChampionForeignKey = Alistar.Id }, + new CharacteristicEntity { Name = "Mana", Value = 278, ChampionForeignKey = Alistar.Id }, + + new CharacteristicEntity { Name = "Ability Power", Value = 30, ChampionForeignKey = Bard.Id }, + new CharacteristicEntity { Name = "Attack Speed", Value = 1, ChampionForeignKey = Bard.Id }, + new CharacteristicEntity { Name = "Health", Value = 535, ChampionForeignKey = Bard.Id }, + new CharacteristicEntity { Name = "Mana", Value = 350, ChampionForeignKey = Bard.Id } ); } diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Program.cs b/src/EntityFramework_LoL/Sources/MyFlib/Program.cs index b40c873..a1a700c 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Program.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Program.cs @@ -5,7 +5,7 @@ using static System.Console; using (var context = new LolDbContext()) { - WriteLine("\nChampions :\n"); + WriteLine("Champions :\n"); foreach (var c in context.Champions) { @@ -18,10 +18,6 @@ using (var context = new LolDbContext()) foreach (var c in context.Champions) { WriteLine($"{c.Name} - {c.Class}"); - /* foreach (var s in c.Skills) - { - WriteLine($"\t\t{s.Name} - {s.Description}"); - }*/ } WriteLine("\nSkills :\n"); @@ -38,7 +34,5 @@ using (var context = new LolDbContext()) WriteLine($"{c.Name} - {c.Description} - Price: {c.Price} - ChampionId: {c.ChampionForeignKey}"); } - WriteLine("\nRunes :\n"); - context.SaveChangesAsync(); // or context.SaveChangesAsync } \ No newline at end of file diff --git a/src/EntityFramework_LoL/Sources/Tests/UT_EF/SkillsTest.cs b/src/EntityFramework_LoL/Sources/Tests/UT_EF/SkillsTest.cs index 1fa7c88..1c5a5f2 100644 --- a/src/EntityFramework_LoL/Sources/Tests/UT_EF/SkillsTest.cs +++ b/src/EntityFramework_LoL/Sources/Tests/UT_EF/SkillsTest.cs @@ -19,10 +19,10 @@ namespace UT_EF using (var context = new LolDbContext(options)) { - SkillEntity fireBall = new SkillEntity { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Basic }; - SkillEntity whiteStar = new SkillEntity { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate }; - SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic }; - SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate }; + SkillEntity fireBall = new SkillEntity { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Basic, ChampionForeignKey = Guid.Parse("{234F5E7F-F196-4C88-AD1C-6C392AA2E038}") }; + SkillEntity whiteStar = new SkillEntity { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = Guid.Parse("{15E0C4F4-4C04-4CCE-8F4D-78F37F63E63F}") }; + SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic, ChampionForeignKey = Guid.Parse("{F32FA768-A1DC-4F6A-9366-FFEC6B0D4159}") }; + SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = Guid.Parse("{F32FA768-A1DC-4F6A-9366-FFEC6B0D4159}") }; context.Skills.AddRange(fireBall, whiteStar, yasuoTempest, LuxFinal); context.SaveChanges(); @@ -44,10 +44,10 @@ namespace UT_EF using (var context = new LolDbContext(options)) { - SkillEntity fireBall = new SkillEntity { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Unknown }; - SkillEntity whiteStar = new SkillEntity { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate }; - SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic }; - SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate }; + SkillEntity fireBall = new SkillEntity { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Basic, ChampionForeignKey = Guid.Parse("{234F5E7F-F196-4C88-AD1C-6C392AA2E038}") }; + SkillEntity whiteStar = new SkillEntity { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = Guid.Parse("{15E0C4F4-4C04-4CCE-8F4D-78F37F63E63F}") }; + SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic, ChampionForeignKey = Guid.Parse("{F32FA768-A1DC-4F6A-9366-FFEC6B0D4159}") }; + SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = Guid.Parse("{F32FA768-A1DC-4F6A-9366-FFEC6B0D4159}") }; context.Skills.AddRange(fireBall, whiteStar, yasuoTempest, LuxFinal); context.SaveChanges(); @@ -87,10 +87,10 @@ namespace UT_EF using (var context = new LolDbContext(options)) { - SkillEntity fireBall = new SkillEntity { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Basic }; - SkillEntity whiteStar = new SkillEntity { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate }; - SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic }; - SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate }; + SkillEntity fireBall = new SkillEntity { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Basic, ChampionForeignKey = Guid.Parse("{234F5E7F-F196-4C88-AD1C-6C392AA2E038}") }; + SkillEntity whiteStar = new SkillEntity { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = Guid.Parse("{15E0C4F4-4C04-4CCE-8F4D-78F37F63E63F}") }; + SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic, ChampionForeignKey = Guid.Parse("{F32FA768-A1DC-4F6A-9366-FFEC6B0D4159}") }; + SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = Guid.Parse("{F32FA768-A1DC-4F6A-9366-FFEC6B0D4159}") }; context.Skills.AddRange(fireBall, whiteStar, yasuoTempest, LuxFinal); context.SaveChanges(); -- 2.36.3 From 82984ee4d6b562ae833145a03fc9af90d6c9657a Mon Sep 17 00:00:00 2001 From: Emre Date: Sun, 19 Mar 2023 11:59:51 +0100 Subject: [PATCH 2/4] Added more UT for the Entities :+1: --- .../Sources/MyFlib/DataBase.db | Bin 131072 -> 131072 bytes .../Sources/MyFlib/LolDbContext.cs | 2 +- .../Sources/Tests/UT_EF/RunePagesTest.cs | 82 ++++++++++++ .../Sources/Tests/UT_EF/RunesTest.cs | 121 ++++++++++++++++++ 4 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 src/EntityFramework_LoL/Sources/Tests/UT_EF/RunePagesTest.cs create mode 100644 src/EntityFramework_LoL/Sources/Tests/UT_EF/RunesTest.cs diff --git a/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db b/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db index 3dcabb2bae26f5c90a464576cc24af0bdd1daae8..59a1e3911cadba4db5b050e974c66d7b91eca2ac 100644 GIT binary patch delta 1915 zcmb`IU2GIp6vywGnVs2>nYp_y?X>KcT^0gepv`V81*`(4=|dx=Euj=bv6N*48`^^G zF4$JeHl#vg(o#mb7?p~RltjZSW3n+wAW=gIny7?mAN;6_4w9X^aOil4^$d;kOYAc#{hdF1~b5|&lD=md4;|~=;Z8YSW6tb1?eV)**9@$^x68r zt~Carw>H|bCGu?Tx|Zr~t-D&o@yM=dEFKNBP&eeVwgjjwnE;tojw5C9MBO~5oZe>cn%1Nox%q{fc#fdakQrr`P3Q)!_KaydbKd0Am5!SW+OF(bC6 zKZrmCL_#clU4Xs27v?n3}$;}3$ zV9AYT3TxjP-O&-VhwP$;*~~4+6^(-?T~)jAB{Et&D|^SS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R@AK5UdVpcSf%Q}sYNO$$cJ$kIA9MIFrz>BtegE&|yDvN1&f z1X@8JDA9TeSpadG(}oCCO4y{D6~$S17?y#u2$ULjy#waqg@Qc@nW{v{fJ~IMLmdC^ ze0G8<-db62Xsn*{)&rS?yEQ#0r|=d4zS+^ACV3-kS7bZLRCx%>IE0)IT?r%{t@L0S zonVLAfK~)-k{u-jS|LX{&1=IT0s<*Vdm2_!iLSTe@`I?#NQ!j01jg!vHZ8gVn*uma zFR7%EDLIv!B7g;82T=%hkqt}FODVtuWYO3JbWVgr1y3t7DNJ$FFlR{-XYJEADHHoc z=yg}XEuLY-kHrt6biO8@fx=l9H`TJu=%Ms;V>W?4FXFg`YzWP!mYw);Jz9mMg31W| zim4XYch7I|E2<`{yQ@_9W%p%%g`m2h^xR-y;r{VRi`!?O!re+-2>1r>ezg*Au^IZ!9t+QqML5&60MKu>iIVm@maqt{OjS}8*FSuV{Ntk7iQyQnqb4ar=Ux; z#l1E0lN{RPdWze}2<%CwiV;5GukqjGmwS@#D0`DVIemdF{IMsYlJ~RL?{w7U962o3 zK;PxuA2Bz~_t>NK;YAA<(H99_Z(=~<*? zu0v0AW5W!5M`8X#En}pIaLU62U_Dm$rvzcx>Lsk^hS)JhS4WrV420#PbYv zNpFjn#q*G~-w`Lyzk>GFoay6h=^>Mf2yoLQ7iVo7LG@Pj99rr2!aF~){~X#YT4yh! zmDcsQQ0N)A*v>##enRXQ+r@GFq`C|Qm%~k!(dWjg=Q{We!cBiM-1QS1&Y=boxoH!> z%KFAQDqrA!g=(Nn=%3a(4gjAQKNE1i^^4c(IpD!J?u9vP*R0aT(T07-j``RPleNb0 tpd^$xFztlB6c`7KHQ7Msb=+{z_qbt$nh$!mnN14q?U6{gb@>k3^j}rR@(ut1 diff --git a/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs index 845f521..2675f56 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs @@ -18,7 +18,7 @@ namespace MyFlib public DbSet Runes { get; set; } public DbSet CategoryRunes { get; set; } public DbSet RunePages { get; set; } - + public DbSet Characteristic { get; set; } public LolDbContext() { } diff --git a/src/EntityFramework_LoL/Sources/Tests/UT_EF/RunePagesTest.cs b/src/EntityFramework_LoL/Sources/Tests/UT_EF/RunePagesTest.cs new file mode 100644 index 0000000..966846d --- /dev/null +++ b/src/EntityFramework_LoL/Sources/Tests/UT_EF/RunePagesTest.cs @@ -0,0 +1,82 @@ +using Microsoft.EntityFrameworkCore; +using MyFlib; +using MyFlib.Entities; +using MyFlib.Entities.enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace UT_EF +{ + public class RunePagesTest + { + [Fact] + public void TestAdd() + { + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(databaseName: "Add_Test_RunePage_database") + .Options; + + using (var context = new LolDbContext(options)) + { + RuneEntity runeHextech = new RuneEntity { Name = "Hextech Flashtraption ", Description = "While Flash is on cooldown, it is replaced by Hexflash.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RunePageEntity page1 = new RunePageEntity { Name = "Page 1" }; + RunePageEntity page2 = new RunePageEntity { Name = "Page 2" }; + DictionaryCategoryRune dictionary = new DictionaryCategoryRune { category = CategoryEntity.Major, RuneName = runeHextech.Name, RunePageName = page1.Name }; + + context.CategoryRunes.Add(dictionary); + context.RunePages.AddRange(page1, page2); + context.SaveChanges(); + } + + using (var context = new LolDbContext(options)) + { + Assert.Equal(2, context.RunePages.Count()); + Assert.Equal("Page 1", context.RunePages.First().Name); + } + } + + [Fact] + public void Delete_Test() + { + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(databaseName: "Delete_Test_RunePage_database") + .Options; + + using (var context = new LolDbContext(options)) + { + + RuneEntity runeHextech = new RuneEntity { Name = "Hextech Flashtraption ", Description = "While Flash is on cooldown, it is replaced by Hexflash.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RunePageEntity page1 = new RunePageEntity { Name = "Page 1" }; + RunePageEntity page2 = new RunePageEntity { Name = "Page 2" }; + DictionaryCategoryRune dictionary = new DictionaryCategoryRune { category = CategoryEntity.Major, RuneName = runeHextech.Name, RunePageName = page1.Name }; + + context.CategoryRunes.Add(dictionary); + context.RunePages.AddRange(page1, page2); + context.SaveChanges(); + } + + using (var context = new LolDbContext(options)) + { + var ewok = context.RunePages.First(); + string nameToFind = "1"; + Assert.Equal(1, context.RunePages.Where(c => c.Name.ToLower().Contains(nameToFind)).Count()); + Assert.Equal(2, context.RunePages.Count()); + context.RunePages.Remove(ewok); + context.SaveChanges(); + + } + + using (var context = new LolDbContext(options)) + { + string nameToFind = "1"; + Assert.Equal(0, context.RunePages.Where(c => c.Name.ToLower().Contains(nameToFind)).Count()); + Assert.Equal(1, context.RunePages.Count()); + + } + + } + } +} diff --git a/src/EntityFramework_LoL/Sources/Tests/UT_EF/RunesTest.cs b/src/EntityFramework_LoL/Sources/Tests/UT_EF/RunesTest.cs new file mode 100644 index 0000000..6b004d5 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/Tests/UT_EF/RunesTest.cs @@ -0,0 +1,121 @@ +using Microsoft.EntityFrameworkCore; +using MyFlib; +using MyFlib.Entities.enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace UT_EF +{ + public class RunesTest + { + [Fact] + public void TestAdd() + { + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(databaseName: "Add_Test_Rune_database") + .Options; + + using (var context = new LolDbContext(options)) + { + RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity electrocute = new RuneEntity { Name = "Electrocute", Description = "hitting an enemy champion with 3 separate attacks or abilities within 3 seconds deals bonus damage.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{e7c87f12-2c7b-44d5-8867-eba1ae5a4657}") }; + RuneEntity pressTheAttack = new RuneEntity { Name = "Press the Attack", Description = "hitting an enemy champion with 3 consecutive basic attacks deals bonus damage and makes them take increased damage from all sources for a short period of time.", Family = RuneFamilyEntity.Precision, ImageId = Guid.Parse("{7c354729-5ecf-43d8-ae73-153740e87644}") }; + + context.Runes.AddRange(conqueror, ravenousHunter, electrocute, pressTheAttack); + context.SaveChanges(); + } + + using (var context = new LolDbContext(options)) + { + Assert.Equal(4, context.Runes.Count()); + Assert.Equal("Conqueror", context.Runes.First().Name); + } + } + + [Fact] + public void Modify_Test() + { + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(databaseName: "Modify_Test_Rune_database") + .Options; + + using (var context = new LolDbContext(options)) + { + RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity electrocute = new RuneEntity { Name = "Electrocute", Description = "hitting an enemy champion with 3 separate attacks or abilities within 3 seconds deals bonus damage.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{e7c87f12-2c7b-44d5-8867-eba1ae5a4657}") }; + RuneEntity pressTheAttack = new RuneEntity { Name = "Press the Attack", Description = "hitting an enemy champion with 3 consecutive basic attacks deals bonus damage and makes them take increased damage from all sources for a short period of time.", Family = RuneFamilyEntity.Precision, ImageId = Guid.Parse("{7c354729-5ecf-43d8-ae73-153740e87644}") }; + + context.Runes.AddRange(conqueror, ravenousHunter, electrocute, pressTheAttack); + context.SaveChanges(); + } + + using (var context = new LolDbContext(options)) + { + string bioToFind = "stacks"; + RuneFamilyEntity type = RuneFamilyEntity.Domination; + Assert.Equal(2, context.Runes.Where(c => c.Description.ToLower().Contains(bioToFind)).Count()); + Assert.Equal(2, context.Runes.Where(c => c.Family == type).Count()); + bioToFind = "dealing damage"; + Assert.Equal(1, context.Runes.Where(c => c.Description.ToLower().Contains(bioToFind)).Count()); + var ewok = context.Runes.Where(c => c.Description.ToLower().Contains(bioToFind)).First(); + ewok.Description = "Rune resist"; + ewok.Family = type; + context.SaveChanges(); + } + + using (var context = new LolDbContext(options)) + { + string bioToFind = "stacks"; + Assert.Equal(1, context.Runes.Where(c => c.Description.ToLower().Contains(bioToFind)).Count()); + bioToFind = "rune resist"; + RuneFamilyEntity type = RuneFamilyEntity.Domination; + Assert.Equal(1, context.Runes.Where(c => c.Description.ToLower().Contains(bioToFind)).Count()); + Assert.Equal(3, context.Runes.Where(c => c.Family == type).Count()); + } + } + + [Fact] + public void Delete_Test() + { + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(databaseName: "Delete_Test_Rune_database") + .Options; + + using (var context = new LolDbContext(options)) + { + RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity electrocute = new RuneEntity { Name = "Electrocute", Description = "hitting an enemy champion with 3 separate attacks or abilities within 3 seconds deals bonus damage.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{e7c87f12-2c7b-44d5-8867-eba1ae5a4657}") }; + RuneEntity pressTheAttack = new RuneEntity { Name = "Press the Attack", Description = "hitting an enemy champion with 3 consecutive basic attacks deals bonus damage and makes them take increased damage from all sources for a short period of time.", Family = RuneFamilyEntity.Precision, ImageId = Guid.Parse("{7c354729-5ecf-43d8-ae73-153740e87644}") }; + + context.Runes.AddRange(conqueror, ravenousHunter, electrocute, pressTheAttack); + context.SaveChanges(); + } + + using (var context = new LolDbContext(options)) + { + var ewok = context.Runes.First(); + string nameToFind = "conqueror"; + Assert.Equal(1, context.Runes.Where(c => c.Name.ToLower().Contains(nameToFind)).Count()); + Assert.Equal(4, context.Runes.Count()); + context.Runes.Remove(ewok); + context.SaveChanges(); + + } + + using (var context = new LolDbContext(options)) + { + string nameToFind = "conqueror"; + Assert.Equal(0, context.Runes.Where(c => c.Name.ToLower().Contains(nameToFind)).Count()); + Assert.Equal(3, context.Runes.Count()); + + } + + } + } +} -- 2.36.3 From 620d50c97d91151ad69585c563223352b0683629 Mon Sep 17 00:00:00 2001 From: Emre Date: Sun, 19 Mar 2023 12:39:59 +0100 Subject: [PATCH 3/4] Create DbManager :hammer: --- .../Controllers/WeatherForecastController.cs | 9 -- .../Sources/DTO/LargeImageDto.cs | 8 +- .../Sources/DTO/PageRequest.cs | 8 +- .../Sources/DTO/PageResponse.cs | 8 +- .../Sources/DTO/RuneDto.cs | 5 - .../Sources/DTO/SkillDto.cs | 8 +- .../Sources/DTO/SkinDto.cs | 8 +- .../Sources/DTO/SkinDtoC.cs | 8 +- .../Sources/DTO/enums/ChampionClassDto.cs | 8 +- .../Sources/DTO/enums/RuneFamilyDto.cs | 8 +- .../Sources/DTO/enums/SkillTypeDto.cs | 8 +- .../Sources/DbManager/DbManager.Champions.cs | 105 ++++++++++++++++++ .../Sources/DbManager/DbManager.RunePages.cs | 80 +++++++++++++ .../Sources/DbManager/DbManager.Runes.cs | 70 ++++++++++++ .../Sources/DbManager/DbManager.Skins.cs | 71 ++++++++++++ .../Sources/DbManager/DbManager.cs | 27 +++++ .../Sources/DbManager/DbManager.csproj | 15 +++ .../Sources/DbManager/Program.cs | 2 + .../Sources/LeagueOfLegends.sln | 14 ++- .../Sources/MyFlib/DataSeeder.cs | 6 - .../Sources/MyFlib/Entities/ChampionEntity.cs | 5 - .../MyFlib/Entities/CharacteristicEntity.cs | 7 +- .../MyFlib/Entities/DictionaryCategoryRune.cs | 5 - .../MyFlib/Entities/LargeImageEntity.cs | 7 +- .../Sources/MyFlib/Entities/RuneEntity.cs | 5 - .../Sources/MyFlib/Entities/RunePageEntity.cs | 7 +- .../Sources/MyFlib/Entities/SkillEntity.cs | 7 +- .../Sources/MyFlib/Entities/SkinEntity.cs | 7 +- .../MyFlib/Entities/enums/CategoryEntity.cs | 8 +- .../Entities/enums/ChampionClassEntity.cs | 8 +- .../MyFlib/Entities/enums/RuneFamilyEntity.cs | 8 +- .../MyFlib/Entities/enums/SkillTypeEntity.cs | 8 +- .../Sources/MyFlib/LolDbContext.cs | 5 - 33 files changed, 398 insertions(+), 165 deletions(-) create mode 100644 src/EntityFramework_LoL/Sources/DbManager/DbManager.Champions.cs create mode 100644 src/EntityFramework_LoL/Sources/DbManager/DbManager.RunePages.cs create mode 100644 src/EntityFramework_LoL/Sources/DbManager/DbManager.Runes.cs create mode 100644 src/EntityFramework_LoL/Sources/DbManager/DbManager.Skins.cs create mode 100644 src/EntityFramework_LoL/Sources/DbManager/DbManager.cs create mode 100644 src/EntityFramework_LoL/Sources/DbManager/DbManager.csproj create mode 100644 src/EntityFramework_LoL/Sources/DbManager/Program.cs diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/WeatherForecastController.cs b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/WeatherForecastController.cs index cf9e709..3c0f0e8 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/WeatherForecastController.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/WeatherForecastController.cs @@ -1,6 +1,4 @@ -using ApiLol.Mapper; using Microsoft.AspNetCore.Mvc; -using Model; namespace ApiLol.Controllers { @@ -23,13 +21,6 @@ namespace ApiLol.Controllers [HttpGet(Name = "GetWeatherForecast")] public IEnumerable Get() { - /* - var champion = new Champion(""); - - //var dtop = ChampionMapper.ToDto(champion); - - var dto = champion.ToDto();*/ - return Enumerable.Range(1, 5).Select(index => new WeatherForecast { Date = DateTime.Now.AddDays(index), diff --git a/src/EntityFramework_LoL/Sources/DTO/LargeImageDto.cs b/src/EntityFramework_LoL/Sources/DTO/LargeImageDto.cs index 133ac67..cc3036b 100644 --- a/src/EntityFramework_LoL/Sources/DTO/LargeImageDto.cs +++ b/src/EntityFramework_LoL/Sources/DTO/LargeImageDto.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DTO +namespace DTO { public class LargeImageDto { diff --git a/src/EntityFramework_LoL/Sources/DTO/PageRequest.cs b/src/EntityFramework_LoL/Sources/DTO/PageRequest.cs index 2631eee..d23cbe2 100644 --- a/src/EntityFramework_LoL/Sources/DTO/PageRequest.cs +++ b/src/EntityFramework_LoL/Sources/DTO/PageRequest.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DTO +namespace DTO { public class PageRequest { diff --git a/src/EntityFramework_LoL/Sources/DTO/PageResponse.cs b/src/EntityFramework_LoL/Sources/DTO/PageResponse.cs index c2d0fc4..1c57ddd 100644 --- a/src/EntityFramework_LoL/Sources/DTO/PageResponse.cs +++ b/src/EntityFramework_LoL/Sources/DTO/PageResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DTO +namespace DTO { public class PageResponse { diff --git a/src/EntityFramework_LoL/Sources/DTO/RuneDto.cs b/src/EntityFramework_LoL/Sources/DTO/RuneDto.cs index 9b20766..8839e07 100644 --- a/src/EntityFramework_LoL/Sources/DTO/RuneDto.cs +++ b/src/EntityFramework_LoL/Sources/DTO/RuneDto.cs @@ -1,9 +1,4 @@ using DTO.enums; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace DTO { diff --git a/src/EntityFramework_LoL/Sources/DTO/SkillDto.cs b/src/EntityFramework_LoL/Sources/DTO/SkillDto.cs index f0e1919..d69d5fb 100644 --- a/src/EntityFramework_LoL/Sources/DTO/SkillDto.cs +++ b/src/EntityFramework_LoL/Sources/DTO/SkillDto.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DTO +namespace DTO { public class SkillDto { diff --git a/src/EntityFramework_LoL/Sources/DTO/SkinDto.cs b/src/EntityFramework_LoL/Sources/DTO/SkinDto.cs index 8ff7cca..bbbf2ff 100644 --- a/src/EntityFramework_LoL/Sources/DTO/SkinDto.cs +++ b/src/EntityFramework_LoL/Sources/DTO/SkinDto.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DTO +namespace DTO { public class SkinDto { diff --git a/src/EntityFramework_LoL/Sources/DTO/SkinDtoC.cs b/src/EntityFramework_LoL/Sources/DTO/SkinDtoC.cs index 656fb33..13ffd48 100644 --- a/src/EntityFramework_LoL/Sources/DTO/SkinDtoC.cs +++ b/src/EntityFramework_LoL/Sources/DTO/SkinDtoC.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DTO +namespace DTO { public class SkinDtoC { diff --git a/src/EntityFramework_LoL/Sources/DTO/enums/ChampionClassDto.cs b/src/EntityFramework_LoL/Sources/DTO/enums/ChampionClassDto.cs index 2f7e82d..91b2cba 100644 --- a/src/EntityFramework_LoL/Sources/DTO/enums/ChampionClassDto.cs +++ b/src/EntityFramework_LoL/Sources/DTO/enums/ChampionClassDto.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DTO +namespace DTO { public enum ChampionClassDto { diff --git a/src/EntityFramework_LoL/Sources/DTO/enums/RuneFamilyDto.cs b/src/EntityFramework_LoL/Sources/DTO/enums/RuneFamilyDto.cs index 053249c..0d61fd5 100644 --- a/src/EntityFramework_LoL/Sources/DTO/enums/RuneFamilyDto.cs +++ b/src/EntityFramework_LoL/Sources/DTO/enums/RuneFamilyDto.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DTO.enums +namespace DTO.enums { public enum RuneFamilyDto { diff --git a/src/EntityFramework_LoL/Sources/DTO/enums/SkillTypeDto.cs b/src/EntityFramework_LoL/Sources/DTO/enums/SkillTypeDto.cs index f416bdd..23165d0 100644 --- a/src/EntityFramework_LoL/Sources/DTO/enums/SkillTypeDto.cs +++ b/src/EntityFramework_LoL/Sources/DTO/enums/SkillTypeDto.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DTO +namespace DTO { public enum SkillTypeDto { diff --git a/src/EntityFramework_LoL/Sources/DbManager/DbManager.Champions.cs b/src/EntityFramework_LoL/Sources/DbManager/DbManager.Champions.cs new file mode 100644 index 0000000..16a2328 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/DbManager.Champions.cs @@ -0,0 +1,105 @@ +using Model; + +namespace DbManager +{ + public partial class DbManager + { + public class ChampionsManager : IChampionsManager + { + private readonly DbManager parent; + + public ChampionsManager(DbManager parent) + => this.parent = parent; + + public Task AddItem(Champion? item) + { + throw new NotImplementedException(); + } + + public Task DeleteItem(Champion? item) + { + throw new NotImplementedException(); + } + + public Task> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsByClass(ChampionClass championClass, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsBySkill(Skill? skill, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsBySkill(string skill, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task GetNbItems() + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByCharacteristic(string charName) + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByClass(ChampionClass championClass) + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByName(string substring) + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByRunePage(RunePage? runePage) + { + throw new NotImplementedException(); + } + + public Task GetNbItemsBySkill(Skill? skill) + { + throw new NotImplementedException(); + } + + public Task GetNbItemsBySkill(string skill) + { + throw new NotImplementedException(); + } + + public Task UpdateItem(Champion? oldItem, Champion? newItem) + { + throw new NotImplementedException(); + } + } + } +} diff --git a/src/EntityFramework_LoL/Sources/DbManager/DbManager.RunePages.cs b/src/EntityFramework_LoL/Sources/DbManager/DbManager.RunePages.cs new file mode 100644 index 0000000..d3b54d2 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/DbManager.RunePages.cs @@ -0,0 +1,80 @@ +using Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DbManager +{ + public partial class DbManager + { + public class RunePagesManager : IRunePagesManager + { + private readonly DbManager parent; + + public RunePagesManager(DbManager parent) + => this.parent = parent; + + public Task AddItem(RunePage? item) + { + throw new NotImplementedException(); + } + + public Task DeleteItem(RunePage? item) + { + throw new NotImplementedException(); + } + + public Task> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsByRune(Model.Rune? rune, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task GetNbItems() + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByChampion(Champion? champion) + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByName(string substring) + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByRune(Model.Rune? rune) + { + throw new NotImplementedException(); + } + + public Task UpdateItem(RunePage? oldItem, RunePage? newItem) + { + throw new NotImplementedException(); + } + } + } +} diff --git a/src/EntityFramework_LoL/Sources/DbManager/DbManager.Runes.cs b/src/EntityFramework_LoL/Sources/DbManager/DbManager.Runes.cs new file mode 100644 index 0000000..ec2abfa --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/DbManager.Runes.cs @@ -0,0 +1,70 @@ +using Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DbManager +{ + public partial class DbManager + { + public class RunesManager : IRunesManager + { + private readonly DbManager parent; + public RunesManager(DbManager parent) + => this.parent = parent; + + public Task AddItem(Model.Rune? item) + { + throw new NotImplementedException(); + } + + public Task DeleteItem(Model.Rune? item) + { + throw new NotImplementedException(); + } + + public Task> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsByFamily(RuneFamily family, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task GetNbItems() + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByFamily(RuneFamily family) + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByName(string substring) + { + throw new NotImplementedException(); + } + + public Task UpdateItem(Model.Rune? oldItem, Model.Rune? newItem) + { + throw new NotImplementedException(); + } + } + + } +} diff --git a/src/EntityFramework_LoL/Sources/DbManager/DbManager.Skins.cs b/src/EntityFramework_LoL/Sources/DbManager/DbManager.Skins.cs new file mode 100644 index 0000000..cb5ecc8 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/DbManager.Skins.cs @@ -0,0 +1,71 @@ +using Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DbManager +{ + public partial class DbManager + { + public class SkinsManager : ISkinsManager + { + private readonly DbManager parent; + + public SkinsManager(DbManager parent) + => this.parent = parent; + + public Task AddItem(Skin? item) + { + throw new NotImplementedException(); + } + + public Task DeleteItem(Skin? item) + { + throw new NotImplementedException(); + } + + public Task> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task GetNbItems() + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByChampion(Champion? champion) + { + throw new NotImplementedException(); + } + + public Task GetNbItemsByName(string substring) + { + throw new NotImplementedException(); + } + + public Task UpdateItem(Skin? oldItem, Skin? newItem) + { + throw new NotImplementedException(); + } + } + + } +} diff --git a/src/EntityFramework_LoL/Sources/DbManager/DbManager.cs b/src/EntityFramework_LoL/Sources/DbManager/DbManager.cs new file mode 100644 index 0000000..33fae54 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/DbManager.cs @@ -0,0 +1,27 @@ +using Model; +using MyFlib; + +namespace DbManager +{ + public partial class DbManager : IDataManager + { + protected LolDbContext DbContext { get; set; } + + public DbManager(LolDbContext dbContext) + { + DbContext = dbContext; + ChampionsMgr = new ChampionsManager(this); + SkinsMgr = new SkinsManager(this); + RunesMgr = new RunesManager(this); + RunePagesMgr = new RunePagesManager(this); + } + + public IChampionsManager ChampionsMgr { get; set; } + + public ISkinsManager SkinsMgr { get; set; } + + public IRunesManager RunesMgr { get; set; } + + public IRunePagesManager RunePagesMgr { get; set; } + } +} diff --git a/src/EntityFramework_LoL/Sources/DbManager/DbManager.csproj b/src/EntityFramework_LoL/Sources/DbManager/DbManager.csproj new file mode 100644 index 0000000..48db0d4 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/DbManager.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + diff --git a/src/EntityFramework_LoL/Sources/DbManager/Program.cs b/src/EntityFramework_LoL/Sources/DbManager/Program.cs new file mode 100644 index 0000000..3751555 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln b/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln index e57cb50..e0e137e 100644 --- a/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln +++ b/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln @@ -19,13 +19,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiLol", "ApiLol\ApiLol.csp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{3919E408-EB12-4422-989B-C6ED4816D465}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiTests", "Tests\ApiTests\ApiTests.csproj", "{1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiTests", "Tests\ApiTests\ApiTests.csproj", "{1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client\Client.csproj", "{464DAB04-BE65-429D-9A39-3E1BB43C521A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{464DAB04-BE65-429D-9A39-3E1BB43C521A}" - Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyFlib", "MyFlib\MyFlib.csproj", "{2142AB69-B483-4B0A-96DC-CFA87DEB11A5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UT_EF", "Tests\UT_EF\UT_EF.csproj", "{F896C30B-A6FE-42B2-BAC8-08360BC48DC6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UT_EF", "Tests\UT_EF\UT_EF.csproj", "{F896C30B-A6FE-42B2-BAC8-08360BC48DC6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbManager", "DbManager\DbManager.csproj", "{71DDCC06-D993-47B0-92E3-5DD6E295FB8B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -73,6 +75,10 @@ Global {F896C30B-A6FE-42B2-BAC8-08360BC48DC6}.Debug|Any CPU.Build.0 = Debug|Any CPU {F896C30B-A6FE-42B2-BAC8-08360BC48DC6}.Release|Any CPU.ActiveCfg = Release|Any CPU {F896C30B-A6FE-42B2-BAC8-08360BC48DC6}.Release|Any CPU.Build.0 = Release|Any CPU + {71DDCC06-D993-47B0-92E3-5DD6E295FB8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {71DDCC06-D993-47B0-92E3-5DD6E295FB8B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {71DDCC06-D993-47B0-92E3-5DD6E295FB8B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {71DDCC06-D993-47B0-92E3-5DD6E295FB8B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/EntityFramework_LoL/Sources/MyFlib/DataSeeder.cs b/src/EntityFramework_LoL/Sources/MyFlib/DataSeeder.cs index cabeb12..12b19ca 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/DataSeeder.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/DataSeeder.cs @@ -1,10 +1,4 @@ using MyFlib.Entities.enums; -using System; -using System.Collections.Generic; -using System.Diagnostics.Metrics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MyFlib { diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/ChampionEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/ChampionEntity.cs index 6b90745..cd06b57 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/ChampionEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/ChampionEntity.cs @@ -1,11 +1,6 @@ using MyFlib.Entities; -using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MyFlib { diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/CharacteristicEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/CharacteristicEntity.cs index cba7944..dd50bb6 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/CharacteristicEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/CharacteristicEntity.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MyFlib.Entities { diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/DictionaryCategoryRune.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/DictionaryCategoryRune.cs index b4b8778..df56137 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/DictionaryCategoryRune.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/DictionaryCategoryRune.cs @@ -1,11 +1,6 @@ using MyFlib.Entities; using MyFlib.Entities.enums; -using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MyFlib { diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/LargeImageEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/LargeImageEntity.cs index b9b3815..9b36b57 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/LargeImageEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/LargeImageEntity.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations; namespace MyFlib { diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/RuneEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/RuneEntity.cs index 9b280d3..5e4c249 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/RuneEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/RuneEntity.cs @@ -1,11 +1,6 @@ using MyFlib.Entities.enums; -using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MyFlib { diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/RunePageEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/RunePageEntity.cs index 66f3c7f..edf5c11 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/RunePageEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/RunePageEntity.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations; namespace MyFlib.Entities { diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkillEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkillEntity.cs index b6349d5..2bed8f4 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkillEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkillEntity.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MyFlib { diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkinEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkinEntity.cs index a2b8518..c4e6270 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkinEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/SkinEntity.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MyFlib { diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/CategoryEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/CategoryEntity.cs index 83863f7..c050236 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/CategoryEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/CategoryEntity.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MyFlib.Entities.enums +namespace MyFlib.Entities.enums { public enum CategoryEntity { diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/ChampionClassEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/ChampionClassEntity.cs index bec72f2..3b0a0bb 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/ChampionClassEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/ChampionClassEntity.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MyFlib +namespace MyFlib { public enum ChampionClassEntity { diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/RuneFamilyEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/RuneFamilyEntity.cs index 9667ba4..d6172c4 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/RuneFamilyEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/RuneFamilyEntity.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MyFlib.Entities.enums +namespace MyFlib.Entities.enums { public enum RuneFamilyEntity { diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/SkillTypeEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/SkillTypeEntity.cs index 73c36e5..9132dd4 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/SkillTypeEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/enums/SkillTypeEntity.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MyFlib +namespace MyFlib { public enum SkillTypeEntity { diff --git a/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs index 2675f56..971d018 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs @@ -1,11 +1,6 @@ using Microsoft.EntityFrameworkCore; using MyFlib.Entities; using MyFlib.Entities.enums; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MyFlib { -- 2.36.3 From 0384119f225b78d91e92696f803126a220ad5094 Mon Sep 17 00:00:00 2001 From: Emre Date: Sun, 19 Mar 2023 20:49:46 +0100 Subject: [PATCH 4/4] Added Mapper to Database :white_check_mark: --- .../Sources/ApiLol/Mapper/ChampionMapper.cs | 7 +-- .../Sources/ApiLol/Mapper/LargeImageMapper.cs | 13 +---- .../Sources/ApiLol/Mapper/RuneMapper.cs | 10 +--- .../Sources/ApiLol/Mapper/SkillMapper.cs | 10 +--- .../Sources/ApiLol/Mapper/SkinMapper.cs | 18 ++---- .../DbManager/Mapper/ChampionMapper.cs | 43 ++++++++++++++ .../DbManager/Mapper/LargeImageMapper.cs | 13 +++++ .../Sources/DbManager/Mapper/RuneMapper.cs | 21 +++++++ .../DbManager/Mapper/RunePageMapper.cs | 24 ++++++++ .../Sources/DbManager/Mapper/SkillMapper.cs | 24 ++++++++ .../Sources/DbManager/Mapper/SkinMapper.cs | 22 +++++++ .../DbManager/Mapper/enums/CategoryMapper.cs | 50 ++++++++++++++++ .../Mapper/enums/ChampionClassMapper.cs | 55 ++++++++++++++++++ .../Mapper/enums/RuneFamilyMapper.cs | 43 ++++++++++++++ .../DbManager/Mapper/enums/SkillTypeMapper.cs | 42 +++++++++++++ .../Sources/MyFlib/DataBase.db | Bin 131072 -> 131072 bytes .../Sources/MyFlib/DataSeeder.cs | 4 +- .../Sources/MyFlib/Entities/RuneEntity.cs | 1 + .../Sources/MyFlib/LolDbContext.cs | 4 +- .../Sources/Tests/UT_EF/RunesTest.cs | 24 ++++---- 20 files changed, 370 insertions(+), 58 deletions(-) create mode 100644 src/EntityFramework_LoL/Sources/DbManager/Mapper/ChampionMapper.cs create mode 100644 src/EntityFramework_LoL/Sources/DbManager/Mapper/LargeImageMapper.cs create mode 100644 src/EntityFramework_LoL/Sources/DbManager/Mapper/RuneMapper.cs create mode 100644 src/EntityFramework_LoL/Sources/DbManager/Mapper/RunePageMapper.cs create mode 100644 src/EntityFramework_LoL/Sources/DbManager/Mapper/SkillMapper.cs create mode 100644 src/EntityFramework_LoL/Sources/DbManager/Mapper/SkinMapper.cs create mode 100644 src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/CategoryMapper.cs create mode 100644 src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/ChampionClassMapper.cs create mode 100644 src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/RuneFamilyMapper.cs create mode 100644 src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/SkillTypeMapper.cs diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs index 094739d..7450581 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs @@ -6,8 +6,7 @@ namespace ApiLol.Mapper public static class ChampionMapper { public static ChampionDto ToDto(this Champion champion) - { - return new ChampionDto() + => new() { Name = champion.Name, Bio = champion.Bio, @@ -17,12 +16,12 @@ namespace ApiLol.Mapper Skins = champion.Skins.Select(e => e.ToDto()), Skills = champion.Skills.Select(e => e.ToDto()) }; - } + public static Champion ToModel(this ChampionDto championDto) { var champ = new Champion(championDto.Name, championDto.Class.ToModel(), championDto.Icon, championDto.Image.Base64, championDto.Bio); - foreach(var skin in championDto.Skins) + foreach (var skin in championDto.Skins) { champ.AddSkin(skin.ToModel(champ)); } diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/LargeImageMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/LargeImageMapper.cs index 6bebb6f..a0b8756 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/LargeImageMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/LargeImageMapper.cs @@ -6,16 +6,9 @@ namespace ApiLol.Mapper public static class LargeImageMapper { public static LargeImageDto ToDto(this LargeImage largeImage) - { - return new LargeImageDto() - { - Base64 = largeImage.Base64 - }; - } + => new() { Base64 = largeImage.Base64 }; + + public static LargeImage ToModel(this LargeImageDto largeImageDto) => new(largeImageDto.Base64); - public static LargeImage ToModel(this LargeImageDto largeImageDto) - { - return new LargeImage(largeImageDto.Base64); - } } } \ No newline at end of file diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RuneMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RuneMapper.cs index af4640e..b11f1aa 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RuneMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RuneMapper.cs @@ -7,8 +7,7 @@ namespace ApiLol.Mapper public static class RuneMapper { public static RuneDto ToDto(this Rune rune) - { - return new RuneDto() + => new() { Name = rune.Name, Description = rune.Description, @@ -16,11 +15,8 @@ namespace ApiLol.Mapper Icon = rune.Icon, Image = rune.Image.ToDto() }; - } - public static Rune ToModel(this RuneDto rune) - { - return new Rune(rune.Name, rune.Family.ToModel(), rune.Icon, rune.Image.Base64, rune.Description); - } + public static Rune ToModel(this RuneDto rune) => new(rune.Name, rune.Family.ToModel(), rune.Icon, rune.Image.Base64, rune.Description); + } } diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkillMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkillMapper.cs index 20c0787..27bb55b 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkillMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkillMapper.cs @@ -6,18 +6,14 @@ namespace ApiLol.Mapper public static class SkillMapper { public static SkillDto ToDto(this Skill skill) - { - return new SkillDto() + => new() { Name = skill.Name, Description = skill.Description, Type = skill.Type.ToDto() }; - } - public static Skill ToModel(this SkillDto skillDto) - { - return new Skill(skillDto.Name, skillDto.Type.ToModel(), skillDto.Description); - } + public static Skill ToModel(this SkillDto skillDto) => new(skillDto.Name, skillDto.Type.ToModel(), skillDto.Description); + } } diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkinMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkinMapper.cs index 776209e..d4d7221 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkinMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkinMapper.cs @@ -6,8 +6,7 @@ namespace ApiLol.Mapper public static class SkinMapper { public static SkinDto ToDto(this Skin skin) - { - return new SkinDto() + => new() { Name = skin.Name, Description = skin.Description, @@ -15,11 +14,9 @@ namespace ApiLol.Mapper Image = skin.Image.ToDto(), Price = skin.Price }; - } public static SkinDtoC ToDtoC(this Skin skin) - { - return new SkinDtoC() + => new() { Name = skin.Name, Description = skin.Description, @@ -28,17 +25,10 @@ namespace ApiLol.Mapper Price = skin.Price, ChampionName = skin.Champion.Name }; - } - public static Skin ToModel(this SkinDto skinDto, Champion champ) - { - return new Skin(skinDto.Name, champ, skinDto.Price, skinDto.Icon, skinDto.Image.Base64, skinDto.Description); - } + public static Skin ToModel(this SkinDto skinDto, Champion champ) => new(skinDto.Name, champ, skinDto.Price, skinDto.Icon, skinDto.Image.Base64, skinDto.Description); - public static Skin ToModelC(this SkinDtoC skinDto, Champion champ) - { - return new Skin(skinDto.Name, champ, skinDto.Price, skinDto.Icon, skinDto.Image.Base64, skinDto.Description); - } + public static Skin ToModelC(this SkinDtoC skinDto, Champion champ) => new(skinDto.Name, champ, skinDto.Price, skinDto.Icon, skinDto.Image.Base64, skinDto.Description); } } \ No newline at end of file diff --git a/src/EntityFramework_LoL/Sources/DbManager/Mapper/ChampionMapper.cs b/src/EntityFramework_LoL/Sources/DbManager/Mapper/ChampionMapper.cs new file mode 100644 index 0000000..454bc54 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/Mapper/ChampionMapper.cs @@ -0,0 +1,43 @@ +using DbManager.Mapper.enums; +using Model; +using MyFlib; + +namespace DbManager.Mapper +{ + public static class ChampionMapper + { + public static Champion ToModel(this ChampionEntity championEntity) + { + Champion champion = new (championEntity.Name, championEntity.Class.ToModel(), championEntity.Icon, championEntity.Image.Base64.ToString(), championEntity.Bio); + foreach (var skill in championEntity.Skills) + { + champion.AddSkill(skill.ToModel()); + } + foreach (var skin in championEntity.Skins) + { + champion.AddSkin(skin.ToModel()); + } + return champion; + } + + public static ChampionEntity ToEntity(this Champion champion, LolDbContext context) + { + var champ = new ChampionEntity() + { + Name = champion.Name, + Icon = champion.Icon, + Bio = champion.Bio, + Image = champion.Image.ToEntity(), + }; + foreach (var skill in champion.Skills) + { + champ.Skills.Add(skill.ToEntity(champ)); + } + foreach (var skin in champion.Skins) + { + champ.Skins.Add(skin.ToEntity(context)); + } + return champ; + } + } +} diff --git a/src/EntityFramework_LoL/Sources/DbManager/Mapper/LargeImageMapper.cs b/src/EntityFramework_LoL/Sources/DbManager/Mapper/LargeImageMapper.cs new file mode 100644 index 0000000..594c0b6 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/Mapper/LargeImageMapper.cs @@ -0,0 +1,13 @@ +using Model; +using MyFlib; + +namespace DbManager.Mapper +{ + public static class LargeImageMapper + { + public static LargeImage ToModel(this LargeImageEntity largeImage) => new(largeImage.Base64); + + public static LargeImageEntity ToEntity(this LargeImage largeImage) => new() { Base64 = largeImage.Base64 }; + + } +} diff --git a/src/EntityFramework_LoL/Sources/DbManager/Mapper/RuneMapper.cs b/src/EntityFramework_LoL/Sources/DbManager/Mapper/RuneMapper.cs new file mode 100644 index 0000000..788ce1e --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/Mapper/RuneMapper.cs @@ -0,0 +1,21 @@ +using DbManager.Mapper.enums; +using Model; +using MyFlib; + +namespace DbManager.Mapper +{ + public static class RuneMapper + { + public static Rune ToModel(this RuneEntity rune) => new(rune.Name, rune.Family.ToModel(), rune.Icon, rune.Image.Base64, rune.Description); + public static RuneEntity ToEntity(this Rune rune) + => new() + { + Name = rune.Name, + Description = rune.Description, + Family = rune.Family.ToEntity(), + Icon = rune.Icon, + Image = rune.Image.ToEntity() + }; + + } +} diff --git a/src/EntityFramework_LoL/Sources/DbManager/Mapper/RunePageMapper.cs b/src/EntityFramework_LoL/Sources/DbManager/Mapper/RunePageMapper.cs new file mode 100644 index 0000000..839ba0e --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/Mapper/RunePageMapper.cs @@ -0,0 +1,24 @@ +using DbManager.Mapper.enums; +using Model; +using MyFlib; +using MyFlib.Entities; + +namespace DbManager.Mapper +{ + public static class RunePageMapper + { + public static RunePage ToModel(this RunePageEntity runePageEntity, LolDbContext context) + { + RunePage runePage = new(runePageEntity.Name); + foreach (var d in runePageEntity.DictionaryCategoryRunes) + { + var rune = context.Runes.Find(d.RuneName); + if (rune!=null) + { + runePage[d.category.ToModel()] = rune.ToModel(); + } + } + return runePage; + } + } +} diff --git a/src/EntityFramework_LoL/Sources/DbManager/Mapper/SkillMapper.cs b/src/EntityFramework_LoL/Sources/DbManager/Mapper/SkillMapper.cs new file mode 100644 index 0000000..9e8b636 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/Mapper/SkillMapper.cs @@ -0,0 +1,24 @@ +using DbManager.Mapper.enums; +using Model; +using MyFlib; + +namespace DbManager.Mapper +{ + public static class SkillMapper + { + public static Skill ToModel(this SkillEntity skillEntity) => new(skillEntity.Name, skillEntity.Type.ToModel(), skillEntity.Description); + + + public static SkillEntity ToEntity(this Skill skill, ChampionEntity championEntity) + { + return new() + { + Name = skill.Name, + Description = skill.Description, + Type = skill.Type.ToEntity(), + Champion = championEntity + }; + } + + } +} diff --git a/src/EntityFramework_LoL/Sources/DbManager/Mapper/SkinMapper.cs b/src/EntityFramework_LoL/Sources/DbManager/Mapper/SkinMapper.cs new file mode 100644 index 0000000..391891f --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/Mapper/SkinMapper.cs @@ -0,0 +1,22 @@ +using Model; +using MyFlib; + +namespace DbManager.Mapper +{ + public static class SkinMapper + { + public static Skin ToModel(this SkinEntity skinEntity) + => new(skinEntity.Name, skinEntity.Champion.ToModel(), skinEntity.Price, skinEntity.Icon, skinEntity.Image.Base64, skinEntity.Description); + + public static SkinEntity ToEntity(this Skin skin, LolDbContext context) + => new() + { + Name = skin.Name, + Description = skin.Description, + Icon = skin.Icon, + Price = skin.Price, + Champion = context.Champions.Find(skin.Champion.Name), + Image = skin.Image.ToEntity() + }; + } +} diff --git a/src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/CategoryMapper.cs b/src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/CategoryMapper.cs new file mode 100644 index 0000000..6b4c872 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/CategoryMapper.cs @@ -0,0 +1,50 @@ +using Model; +using MyFlib.Entities.enums; + +namespace DbManager.Mapper.enums +{ + public static class CategoryMapper + { + public static RunePage.Category ToModel(this CategoryEntity category) + { + switch (category) + { + case CategoryEntity.Major: + return RunePage.Category.Major; + case CategoryEntity.Minor1: + return RunePage.Category.Minor1; + case CategoryEntity.Minor2: + return RunePage.Category.Minor2; + case CategoryEntity.Minor3: + return RunePage.Category.Minor3; + case CategoryEntity.OtherMinor1: + return RunePage.Category.OtherMinor1; + case CategoryEntity.OtherMinor2: + return RunePage.Category.OtherMinor2; + default: + return RunePage.Category.Major; + } + } + + public static CategoryEntity ToEntity(this RunePage.Category category) + { + switch (category) + { + case RunePage.Category.Major: + return CategoryEntity.Major; + case RunePage.Category.Minor1: + return CategoryEntity.Minor1; + case RunePage.Category.Minor2: + return CategoryEntity.Minor2; + case RunePage.Category.Minor3: + return CategoryEntity.Minor3; + case RunePage.Category.OtherMinor1: + return CategoryEntity.OtherMinor1; + case RunePage.Category.OtherMinor2: + return CategoryEntity.OtherMinor2; + default: + return CategoryEntity.Major; + } + } + } +} diff --git a/src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/ChampionClassMapper.cs b/src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/ChampionClassMapper.cs new file mode 100644 index 0000000..a1948a8 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/ChampionClassMapper.cs @@ -0,0 +1,55 @@ +using Model; +using MyFlib; + +namespace DbManager.Mapper.enums +{ + public static class ChampionClassMapper + { + public static ChampionClass ToModel(this ChampionClassEntity championClass) + { + switch (championClass) + { + case ChampionClassEntity.Unknown: + return ChampionClass.Unknown; + case ChampionClassEntity.Assassin: + return ChampionClass.Assassin; + case ChampionClassEntity.Fighter: + return ChampionClass.Fighter; + case ChampionClassEntity.Mage: + return ChampionClass.Mage; + case ChampionClassEntity.Marksman: + return ChampionClass.Marksman; + case ChampionClassEntity.Support: + return ChampionClass.Support; + case ChampionClassEntity.Tank: + return ChampionClass.Tank; + default: + return ChampionClass.Unknown; + } + } + + public static ChampionClassEntity ToEntity(this ChampionClass championClass) + { + switch (championClass) + { + case ChampionClass.Unknown: + return ChampionClassEntity.Unknown; + case ChampionClass.Assassin: + return ChampionClassEntity.Assassin; + case ChampionClass.Fighter: + return ChampionClassEntity.Fighter; + case ChampionClass.Mage: + return ChampionClassEntity.Mage; + case ChampionClass.Marksman: + return ChampionClassEntity.Marksman; + case ChampionClass.Support: + return ChampionClassEntity.Support; + case ChampionClass.Tank: + return ChampionClassEntity.Tank; + default: + return ChampionClassEntity.Unknown; + } + } + + } +} diff --git a/src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/RuneFamilyMapper.cs b/src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/RuneFamilyMapper.cs new file mode 100644 index 0000000..c593f34 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/RuneFamilyMapper.cs @@ -0,0 +1,43 @@ +using Model; +using MyFlib.Entities.enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DbManager.Mapper.enums +{ + public static class RuneFamilyMapper + { + public static RuneFamily ToModel(this RuneFamilyEntity runeFamily) + { + switch (runeFamily) + { + case RuneFamilyEntity.Unknown: + return RuneFamily.Unknown; + case RuneFamilyEntity.Precision: + return RuneFamily.Precision; + case RuneFamilyEntity.Domination: + return RuneFamily.Domination; + default: + return RuneFamily.Unknown; + } + } + + public static RuneFamilyEntity ToEntity(this RuneFamily runeFamily) + { + switch (runeFamily) + { + case RuneFamily.Unknown: + return RuneFamilyEntity.Unknown; + case RuneFamily.Precision: + return RuneFamilyEntity.Precision; + case RuneFamily.Domination: + return RuneFamilyEntity.Domination; + default: + return RuneFamilyEntity.Unknown; + } + } + } +} diff --git a/src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/SkillTypeMapper.cs b/src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/SkillTypeMapper.cs new file mode 100644 index 0000000..f3969e6 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DbManager/Mapper/enums/SkillTypeMapper.cs @@ -0,0 +1,42 @@ +using Model; +using MyFlib; + +namespace DbManager.Mapper.enums +{ + public static class SkillTypeMapper + { + public static SkillType ToModel(this SkillTypeEntity skillTypeEntity) + { + switch (skillTypeEntity) + { + case SkillTypeEntity.Unknown: + return SkillType.Unknown; + case SkillTypeEntity.Basic: + return SkillType.Basic; + case SkillTypeEntity.Passive: + return SkillType.Passive; + case SkillTypeEntity.Ultimate: + return SkillType.Ultimate; + default: + return SkillType.Unknown; + } + } + public static SkillTypeEntity ToEntity(this SkillType skillType) + { + switch (skillType) + { + case SkillType.Unknown: + return SkillTypeEntity.Unknown; + case SkillType.Basic: + return SkillTypeEntity.Basic; + case SkillType.Passive: + return SkillTypeEntity.Passive; + case SkillType.Ultimate: + return SkillTypeEntity.Ultimate; + default: + return SkillTypeEntity.Unknown; + } + + } + } +} diff --git a/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db b/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db index 59a1e3911cadba4db5b050e974c66d7b91eca2ac..298aaffcf9e9caf01d19b8793fc24b632bddd1ac 100644 GIT binary patch delta 4048 zcma)9U2qfE71q`6Y9*}QwGBq`PvFLou?d!uWhs(r6A(tK`AYyJG8u5lB3)Y>NxMS3 zvQdBv+Xnhqf}Gkt-FK6Ivp&a})VZIYh5 zvKjMROLJDMyXW5f-E+Qk_MC$Uod*v(kG3=-8+ss*B7)HIdJr)6oiWO{*`Esbofplc=TIl&tRM6BDYUONtwL7<_fyi^>Okg!P-OE# z8bL4!-Ejd3br(fQky4a&CpQR1MiEnV)OSu0imU;IqN96IgcR}2r_$#0NfZuiN*B@6 z%C%iyywK&oWs}~Mo)^Co-xW6q{}$d7V(wd&2H)py|27vNZxRF)5Bk>nBf&Lmy*1E5!RHa(9*zmCm(MW1Xnz;CfpN@`un}XUZ39^ z2t;DuaLga`_VxKgfnaZ6C=iYfkc6C9vewMrIM2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z_e53e<|6ElP;0dadvmGfVi9(Ld?1WuXc+d( zY)XpTZz;R&H`P=-qBbDmam52di1)q-4|@o)e^a+f8Th}I7DBqyNEg6vmx>|nMh92{ zPGe94L3>gPua_Uc*a`P3=0Gro{;lXlEo^wdegoHHgb^5pq$9Erf*0M&LS!Pakr6+_ zhsZ&g2-GSO{;qUlJ z;$##dA_?gkUY9df4SB#_{>$Py_u@{6Fyjjx&QzG diff --git a/src/EntityFramework_LoL/Sources/MyFlib/DataSeeder.cs b/src/EntityFramework_LoL/Sources/MyFlib/DataSeeder.cs index 12b19ca..b3ba905 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/DataSeeder.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/DataSeeder.cs @@ -29,8 +29,8 @@ namespace MyFlib context.AddRange(yasuoTempest, LuxFinal); // Runes - RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; - RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; context.AddRange(conqueror, ravenousHunter); diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/RuneEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/RuneEntity.cs index 5e4c249..9c6683f 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/Entities/RuneEntity.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/RuneEntity.cs @@ -16,6 +16,7 @@ namespace MyFlib [Required] public RuneFamilyEntity Family { get; set; } public ICollection DictionaryCategoryRunes { get; set; } + public string Icon { get; set; } public LargeImageEntity Image { get; set; } [ForeignKey("Image")] diff --git a/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs index 971d018..e680eb9 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs @@ -73,8 +73,8 @@ namespace MyFlib ); //RuneEntity - RuneEntity runeHextech = new RuneEntity { Name = "Hextech Flashtraption ", Description = "While Flash is on cooldown, it is replaced by Hexflash.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; - RuneEntity runeManaflow = new RuneEntity { Name = "Manaflow Band ", Description = "Hitting enemy champions with a spell grants 25 maximum mana, up to 250 mana.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{9f9086f5-5cc5-47b5-af9b-a935f4e9b89c}") }; + RuneEntity runeHextech = new RuneEntity { Name = "Hextech Flashtraption ", Description = "While Flash is on cooldown, it is replaced by Hexflash.", Family = RuneFamilyEntity.Unknown, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity runeManaflow = new RuneEntity { Name = "Manaflow Band ", Description = "Hitting enemy champions with a spell grants 25 maximum mana, up to 250 mana.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{9f9086f5-5cc5-47b5-af9b-a935f4e9b89c}") }; modelBuilder.Entity().HasData(runeHextech, runeManaflow); //RunePageEntity diff --git a/src/EntityFramework_LoL/Sources/Tests/UT_EF/RunesTest.cs b/src/EntityFramework_LoL/Sources/Tests/UT_EF/RunesTest.cs index 6b004d5..4620f30 100644 --- a/src/EntityFramework_LoL/Sources/Tests/UT_EF/RunesTest.cs +++ b/src/EntityFramework_LoL/Sources/Tests/UT_EF/RunesTest.cs @@ -20,10 +20,10 @@ namespace UT_EF using (var context = new LolDbContext(options)) { - RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; - RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; - RuneEntity electrocute = new RuneEntity { Name = "Electrocute", Description = "hitting an enemy champion with 3 separate attacks or abilities within 3 seconds deals bonus damage.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{e7c87f12-2c7b-44d5-8867-eba1ae5a4657}") }; - RuneEntity pressTheAttack = new RuneEntity { Name = "Press the Attack", Description = "hitting an enemy champion with 3 consecutive basic attacks deals bonus damage and makes them take increased damage from all sources for a short period of time.", Family = RuneFamilyEntity.Precision, ImageId = Guid.Parse("{7c354729-5ecf-43d8-ae73-153740e87644}") }; + RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity electrocute = new RuneEntity { Name = "Electrocute", Description = "hitting an enemy champion with 3 separate attacks or abilities within 3 seconds deals bonus damage.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{e7c87f12-2c7b-44d5-8867-eba1ae5a4657}") }; + RuneEntity pressTheAttack = new RuneEntity { Name = "Press the Attack", Description = "hitting an enemy champion with 3 consecutive basic attacks deals bonus damage and makes them take increased damage from all sources for a short period of time.", Family = RuneFamilyEntity.Precision, Icon = "", ImageId = Guid.Parse("{7c354729-5ecf-43d8-ae73-153740e87644}") }; context.Runes.AddRange(conqueror, ravenousHunter, electrocute, pressTheAttack); context.SaveChanges(); @@ -45,10 +45,10 @@ namespace UT_EF using (var context = new LolDbContext(options)) { - RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; - RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; - RuneEntity electrocute = new RuneEntity { Name = "Electrocute", Description = "hitting an enemy champion with 3 separate attacks or abilities within 3 seconds deals bonus damage.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{e7c87f12-2c7b-44d5-8867-eba1ae5a4657}") }; - RuneEntity pressTheAttack = new RuneEntity { Name = "Press the Attack", Description = "hitting an enemy champion with 3 consecutive basic attacks deals bonus damage and makes them take increased damage from all sources for a short period of time.", Family = RuneFamilyEntity.Precision, ImageId = Guid.Parse("{7c354729-5ecf-43d8-ae73-153740e87644}") }; + RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity electrocute = new RuneEntity { Name = "Electrocute", Description = "hitting an enemy champion with 3 separate attacks or abilities within 3 seconds deals bonus damage.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{e7c87f12-2c7b-44d5-8867-eba1ae5a4657}") }; + RuneEntity pressTheAttack = new RuneEntity { Name = "Press the Attack", Description = "hitting an enemy champion with 3 consecutive basic attacks deals bonus damage and makes them take increased damage from all sources for a short period of time.", Family = RuneFamilyEntity.Precision, Icon = "", ImageId = Guid.Parse("{7c354729-5ecf-43d8-ae73-153740e87644}") }; context.Runes.AddRange(conqueror, ravenousHunter, electrocute, pressTheAttack); context.SaveChanges(); @@ -88,10 +88,10 @@ namespace UT_EF using (var context = new LolDbContext(options)) { - RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; - RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; - RuneEntity electrocute = new RuneEntity { Name = "Electrocute", Description = "hitting an enemy champion with 3 separate attacks or abilities within 3 seconds deals bonus damage.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{e7c87f12-2c7b-44d5-8867-eba1ae5a4657}") }; - RuneEntity pressTheAttack = new RuneEntity { Name = "Press the Attack", Description = "hitting an enemy champion with 3 consecutive basic attacks deals bonus damage and makes them take increased damage from all sources for a short period of time.", Family = RuneFamilyEntity.Precision, ImageId = Guid.Parse("{7c354729-5ecf-43d8-ae73-153740e87644}") }; + RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") }; + RuneEntity electrocute = new RuneEntity { Name = "Electrocute", Description = "hitting an enemy champion with 3 separate attacks or abilities within 3 seconds deals bonus damage.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{e7c87f12-2c7b-44d5-8867-eba1ae5a4657}") }; + RuneEntity pressTheAttack = new RuneEntity { Name = "Press the Attack", Description = "hitting an enemy champion with 3 consecutive basic attacks deals bonus damage and makes them take increased damage from all sources for a short period of time.", Family = RuneFamilyEntity.Precision, Icon = "", ImageId = Guid.Parse("{7c354729-5ecf-43d8-ae73-153740e87644}") }; context.Runes.AddRange(conqueror, ravenousHunter, electrocute, pressTheAttack); context.SaveChanges(); -- 2.36.3