diff --git a/.vs/League-of-Legends_Project3/v17/.wsuo b/.vs/League-of-Legends_Project3/v17/.wsuo new file mode 100644 index 0000000..80c36fc Binary files /dev/null and b/.vs/League-of-Legends_Project3/v17/.wsuo differ diff --git a/EntityFramework_LoL/Sources/Entities/ChampionDbContext.cs b/EntityFramework_LoL/Sources/Entities/ChampionDbContext.cs new file mode 100644 index 0000000..e28b10f --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/ChampionDbContext.cs @@ -0,0 +1,121 @@ +using Microsoft.EntityFrameworkCore; +using Shared; +using System.Reflection.Metadata; +using System.Security.Claims; +using System.Xml.Linq; + +namespace Entities +{ + public class ChampionDbContext : DbContext + { + public DbSet skins { get; set; } + public DbSet champions { get; set; } + public DbSet skills { get; set; } + public DbSet runes { get; set; } + public DbSet runepages { get; set; } + public DbSet largeimages { get; set; } + + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlite($"Data Source=Entities.Champions.db"); + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + + modelBuilder.Entity().Property(e => e.Id).ValueGeneratedOnAdd(); + + modelBuilder.Entity().Property(e => e.Id).ValueGeneratedOnAdd(); + modelBuilder.Entity() + .HasMany(x => x.runes) + .WithMany(x => x.runepages) + .UsingEntity(); + + + modelBuilder.Entity().HasData(new List() + { + new() + { + Id = Guid.NewGuid(), + Base64 = "aaa" + } + }); + + modelBuilder.Entity().HasData(new List() { + new() + { + Name = "Dave", + Bio = "Le meilleur Jazzman de France", + Class = ChampionClass.Fighter, + + }, + new() + { + Name = "Armure", + Bio = "Solide", + Class = ChampionClass.Tank, + } + }); + + modelBuilder.Entity().HasData(new List() { + new SkinEntity + { + Name = "Dave de glace", + Description = "Enneigé", + Icon = "aaa", + ChampionForeignKey = "Dave", + Price=7.99F + }, + new SkinEntity + { + Name = "Armure Fullspeed", + Description = "Deja vu", + Icon = "aaa", + ChampionForeignKey = "Armure", + Price=9.99F + }, + }); + + modelBuilder.Entity().HasData(new List() { + new() + { + Name = "Boule de feu", + Description = "Fire!", + SkillType = SkillType.Basic + }, + new() + { + Name = "White Star", + Description = "Random damage", + SkillType = SkillType.Ultimate + } + }); + + modelBuilder.Entity().HasData(new List() + { + new() + { + Id = Guid.NewGuid(), + Name="Runepage_1" + } + }); + + modelBuilder.Entity().HasData(new List() { + new() + { + Name = "Bullseye", + Description = "Steady shot", + RuneFamily = RuneFamily.Precision + }, + new() + { + Name = "Alkatraz", + Description = "Lock effect", + RuneFamily = RuneFamily.Domination + } + }); + + } + } +} diff --git a/EntityFramework_LoL/Sources/Entities/ChampionEntity.cs b/EntityFramework_LoL/Sources/Entities/ChampionEntity.cs new file mode 100644 index 0000000..5e3101a --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/ChampionEntity.cs @@ -0,0 +1,28 @@ +using Shared; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Entities +{ + public class ChampionEntity + { + [Key] + [MaxLength(256)] + public string Name { get; set; } + [Required] + [MaxLength(500)] + public string Bio { get; set; } + public string? Icon { get; set; } + [Required] + public ChampionClass Class { get; set;} + public virtual ICollection? Skills { get; set; } + + public Guid? ImageId { get; set; } + + [ForeignKey("ImageId")] + public LargeImageEntity? Image { get; set; } + + + + } +} diff --git a/EntityFramework_LoL/Sources/Entities/Entities.Champions.db b/EntityFramework_LoL/Sources/Entities/Entities.Champions.db new file mode 100644 index 0000000..5847519 Binary files /dev/null and b/EntityFramework_LoL/Sources/Entities/Entities.Champions.db differ diff --git a/EntityFramework_LoL/Sources/Entities/Entities.Champions.db-shm b/EntityFramework_LoL/Sources/Entities/Entities.Champions.db-shm new file mode 100644 index 0000000..be1302a Binary files /dev/null and b/EntityFramework_LoL/Sources/Entities/Entities.Champions.db-shm differ diff --git a/EntityFramework_LoL/Sources/Entities/Entities.Champions.db-wal b/EntityFramework_LoL/Sources/Entities/Entities.Champions.db-wal new file mode 100644 index 0000000..d2719b5 Binary files /dev/null and b/EntityFramework_LoL/Sources/Entities/Entities.Champions.db-wal differ diff --git a/EntityFramework_LoL/Sources/Entities/Entities.csproj b/EntityFramework_LoL/Sources/Entities/Entities.csproj new file mode 100644 index 0000000..ef6f098 --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/Entities.csproj @@ -0,0 +1,28 @@ + + + + net6.0 + enable + enable + $(MSBuildProjectDirectory) + Exe + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/EntityFramework_LoL/Sources/Entities/LargeImageEntity.cs b/EntityFramework_LoL/Sources/Entities/LargeImageEntity.cs new file mode 100644 index 0000000..3448ac9 --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/LargeImageEntity.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Entities +{ + public class LargeImageEntity + { + + [Key] + public Guid Id { get; set; } + [Required] + public string Base64 { get; set; } + + } +} diff --git a/EntityFramework_LoL/Sources/Entities/Migrations/20230209133904_myFirstMigration.Designer.cs b/EntityFramework_LoL/Sources/Entities/Migrations/20230209133904_myFirstMigration.Designer.cs new file mode 100644 index 0000000..81f4297 --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/Migrations/20230209133904_myFirstMigration.Designer.cs @@ -0,0 +1,332 @@ +// +using System; +using Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Entities.Migrations +{ + [DbContext(typeof(ChampionDbContext))] + [Migration("20230209133904_myFirstMigration")] + partial class myFirstMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("ChampionEntitySkillEntity", b => + { + b.Property("ChampionsName") + .HasColumnType("TEXT"); + + b.Property("SkillsName") + .HasColumnType("TEXT"); + + b.HasKey("ChampionsName", "SkillsName"); + + b.HasIndex("SkillsName"); + + b.ToTable("ChampionEntitySkillEntity"); + }); + + modelBuilder.Entity("Entities.ChampionEntity", b => + { + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("Bio") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Class") + .HasColumnType("INTEGER"); + + b.Property("Icon") + .HasColumnType("TEXT"); + + b.Property("ImageId") + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex("ImageId"); + + b.ToTable("champions"); + + b.HasData( + new + { + Name = "Dave", + Bio = "Le meilleur Jazzman de France", + Class = 2 + }, + new + { + Name = "Armure", + Bio = "Solide", + Class = 6 + }); + }); + + modelBuilder.Entity("Entities.LargeImageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Base64") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("largeimages"); + + b.HasData( + new + { + Id = new Guid("70d7aace-13a9-40e1-bd94-99790805f6d0"), + Base64 = "aaa" + }); + }); + + modelBuilder.Entity("Entities.RuneEntity", b => + { + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("ImageId") + .HasColumnType("TEXT"); + + b.Property("RuneFamily") + .HasColumnType("INTEGER"); + + b.HasKey("Name"); + + b.HasIndex("ImageId"); + + b.ToTable("runes"); + + b.HasData( + new + { + Name = "Bullseye", + Description = "Steady shot", + RuneFamily = 1 + }, + new + { + Name = "Alkatraz", + Description = "Lock effect", + RuneFamily = 2 + }); + }); + + modelBuilder.Entity("Entities.RunePageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("runepages"); + + b.HasData( + new + { + Id = new Guid("a5a4f69b-5cbb-48c1-beb4-896bc9171714"), + Name = "Runepage_1" + }); + }); + + modelBuilder.Entity("Entities.RunePageRuneEntity", b => + { + b.Property("runepagesId") + .HasColumnType("TEXT"); + + b.Property("runesName") + .HasColumnType("TEXT"); + + b.Property("Category") + .HasColumnType("INTEGER"); + + b.HasKey("runepagesId", "runesName"); + + b.HasIndex("runesName"); + + b.ToTable("RunePageRuneEntity"); + }); + + modelBuilder.Entity("Entities.SkillEntity", b => + { + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("SkillType") + .HasColumnType("INTEGER"); + + b.HasKey("Name"); + + b.ToTable("skills"); + + b.HasData( + new + { + Name = "Boule de feu", + Description = "Fire!", + SkillType = 1 + }, + new + { + Name = "White Star", + Description = "Random damage", + SkillType = 3 + }); + }); + + modelBuilder.Entity("Entities.SkinEntity", b => + { + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("ChampionForeignKey") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ImageId") + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("REAL"); + + b.HasKey("Name"); + + b.HasIndex("ChampionForeignKey"); + + b.HasIndex("ImageId"); + + b.ToTable("skins"); + + b.HasData( + new + { + Name = "Dave de glace", + ChampionForeignKey = "Dave", + Description = "Enneigé", + Icon = "aaa", + Price = 7.99f + }, + new + { + Name = "Armure Fullspeed", + ChampionForeignKey = "Armure", + Description = "Deja vu", + Icon = "aaa", + Price = 9.99f + }); + }); + + modelBuilder.Entity("ChampionEntitySkillEntity", b => + { + b.HasOne("Entities.ChampionEntity", null) + .WithMany() + .HasForeignKey("ChampionsName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.SkillEntity", null) + .WithMany() + .HasForeignKey("SkillsName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entities.ChampionEntity", b => + { + b.HasOne("Entities.LargeImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageId"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("Entities.RuneEntity", b => + { + b.HasOne("Entities.LargeImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageId"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("Entities.RunePageRuneEntity", b => + { + b.HasOne("Entities.RunePageEntity", null) + .WithMany() + .HasForeignKey("runepagesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.RuneEntity", null) + .WithMany() + .HasForeignKey("runesName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entities.SkinEntity", b => + { + b.HasOne("Entities.ChampionEntity", "Champion") + .WithMany() + .HasForeignKey("ChampionForeignKey") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.LargeImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageId"); + + b.Navigation("Champion"); + + b.Navigation("Image"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/EntityFramework_LoL/Sources/Entities/Migrations/20230209133904_myFirstMigration.cs b/EntityFramework_LoL/Sources/Entities/Migrations/20230209133904_myFirstMigration.cs new file mode 100644 index 0000000..eb3748a --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/Migrations/20230209133904_myFirstMigration.cs @@ -0,0 +1,273 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace Entities.Migrations +{ + /// + public partial class myFirstMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "largeimages", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + Base64 = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_largeimages", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "runepages", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + Name = table.Column(type: "TEXT", maxLength: 256, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_runepages", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "skills", + columns: table => new + { + Name = table.Column(type: "TEXT", maxLength: 256, nullable: false), + Description = table.Column(type: "TEXT", maxLength: 500, nullable: false), + SkillType = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_skills", x => x.Name); + }); + + migrationBuilder.CreateTable( + name: "champions", + columns: table => new + { + Name = table.Column(type: "TEXT", maxLength: 256, nullable: false), + Bio = table.Column(type: "TEXT", maxLength: 500, nullable: false), + Icon = table.Column(type: "TEXT", nullable: true), + Class = table.Column(type: "INTEGER", nullable: false), + ImageId = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_champions", x => x.Name); + table.ForeignKey( + name: "FK_champions_largeimages_ImageId", + column: x => x.ImageId, + principalTable: "largeimages", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "runes", + columns: table => new + { + Name = table.Column(type: "TEXT", maxLength: 256, nullable: false), + Description = table.Column(type: "TEXT", maxLength: 500, nullable: false), + RuneFamily = table.Column(type: "INTEGER", nullable: false), + ImageId = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_runes", x => x.Name); + table.ForeignKey( + name: "FK_runes_largeimages_ImageId", + column: x => x.ImageId, + principalTable: "largeimages", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "ChampionEntitySkillEntity", + columns: table => new + { + ChampionsName = table.Column(type: "TEXT", nullable: false), + SkillsName = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ChampionEntitySkillEntity", x => new { x.ChampionsName, x.SkillsName }); + table.ForeignKey( + name: "FK_ChampionEntitySkillEntity_champions_ChampionsName", + column: x => x.ChampionsName, + principalTable: "champions", + principalColumn: "Name", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ChampionEntitySkillEntity_skills_SkillsName", + column: x => x.SkillsName, + principalTable: "skills", + principalColumn: "Name", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "skins", + columns: table => new + { + Name = table.Column(type: "TEXT", maxLength: 256, nullable: false), + Description = table.Column(type: "TEXT", maxLength: 500, nullable: false), + Icon = table.Column(type: "TEXT", nullable: false), + Price = table.Column(type: "REAL", nullable: false), + ChampionForeignKey = table.Column(type: "TEXT", nullable: false), + ImageId = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_skins", x => x.Name); + table.ForeignKey( + name: "FK_skins_champions_ChampionForeignKey", + column: x => x.ChampionForeignKey, + principalTable: "champions", + principalColumn: "Name", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_skins_largeimages_ImageId", + column: x => x.ImageId, + principalTable: "largeimages", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "RunePageRuneEntity", + columns: table => new + { + runepagesId = table.Column(type: "TEXT", nullable: false), + runesName = table.Column(type: "TEXT", nullable: false), + Category = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RunePageRuneEntity", x => new { x.runepagesId, x.runesName }); + table.ForeignKey( + name: "FK_RunePageRuneEntity_runepages_runepagesId", + column: x => x.runepagesId, + principalTable: "runepages", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RunePageRuneEntity_runes_runesName", + column: x => x.runesName, + principalTable: "runes", + principalColumn: "Name", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.InsertData( + table: "champions", + columns: new[] { "Name", "Bio", "Class", "Icon", "ImageId" }, + values: new object[,] + { + { "Armure", "Solide", 6, null, null }, + { "Dave", "Le meilleur Jazzman de France", 2, null, null } + }); + + migrationBuilder.InsertData( + table: "largeimages", + columns: new[] { "Id", "Base64" }, + values: new object[] { new Guid("70d7aace-13a9-40e1-bd94-99790805f6d0"), "aaa" }); + + migrationBuilder.InsertData( + table: "runepages", + columns: new[] { "Id", "Name" }, + values: new object[] { new Guid("a5a4f69b-5cbb-48c1-beb4-896bc9171714"), "Runepage_1" }); + + migrationBuilder.InsertData( + table: "runes", + columns: new[] { "Name", "Description", "ImageId", "RuneFamily" }, + values: new object[,] + { + { "Alkatraz", "Lock effect", null, 2 }, + { "Bullseye", "Steady shot", null, 1 } + }); + + migrationBuilder.InsertData( + table: "skills", + columns: new[] { "Name", "Description", "SkillType" }, + values: new object[,] + { + { "Boule de feu", "Fire!", 1 }, + { "White Star", "Random damage", 3 } + }); + + migrationBuilder.InsertData( + table: "skins", + columns: new[] { "Name", "ChampionForeignKey", "Description", "Icon", "ImageId", "Price" }, + values: new object[,] + { + { "Armure Fullspeed", "Armure", "Deja vu", "aaa", null, 9.99f }, + { "Dave de glace", "Dave", "Enneigé", "aaa", null, 7.99f } + }); + + migrationBuilder.CreateIndex( + name: "IX_ChampionEntitySkillEntity_SkillsName", + table: "ChampionEntitySkillEntity", + column: "SkillsName"); + + migrationBuilder.CreateIndex( + name: "IX_champions_ImageId", + table: "champions", + column: "ImageId"); + + migrationBuilder.CreateIndex( + name: "IX_RunePageRuneEntity_runesName", + table: "RunePageRuneEntity", + column: "runesName"); + + migrationBuilder.CreateIndex( + name: "IX_runes_ImageId", + table: "runes", + column: "ImageId"); + + migrationBuilder.CreateIndex( + name: "IX_skins_ChampionForeignKey", + table: "skins", + column: "ChampionForeignKey"); + + migrationBuilder.CreateIndex( + name: "IX_skins_ImageId", + table: "skins", + column: "ImageId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ChampionEntitySkillEntity"); + + migrationBuilder.DropTable( + name: "RunePageRuneEntity"); + + migrationBuilder.DropTable( + name: "skins"); + + migrationBuilder.DropTable( + name: "skills"); + + migrationBuilder.DropTable( + name: "runepages"); + + migrationBuilder.DropTable( + name: "runes"); + + migrationBuilder.DropTable( + name: "champions"); + + migrationBuilder.DropTable( + name: "largeimages"); + } + } +} diff --git a/EntityFramework_LoL/Sources/Entities/Migrations/ChampionDbContextModelSnapshot.cs b/EntityFramework_LoL/Sources/Entities/Migrations/ChampionDbContextModelSnapshot.cs new file mode 100644 index 0000000..aef1440 --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/Migrations/ChampionDbContextModelSnapshot.cs @@ -0,0 +1,329 @@ +// +using System; +using Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Entities.Migrations +{ + [DbContext(typeof(ChampionDbContext))] + partial class ChampionDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("ChampionEntitySkillEntity", b => + { + b.Property("ChampionsName") + .HasColumnType("TEXT"); + + b.Property("SkillsName") + .HasColumnType("TEXT"); + + b.HasKey("ChampionsName", "SkillsName"); + + b.HasIndex("SkillsName"); + + b.ToTable("ChampionEntitySkillEntity"); + }); + + modelBuilder.Entity("Entities.ChampionEntity", b => + { + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("Bio") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Class") + .HasColumnType("INTEGER"); + + b.Property("Icon") + .HasColumnType("TEXT"); + + b.Property("ImageId") + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex("ImageId"); + + b.ToTable("champions"); + + b.HasData( + new + { + Name = "Dave", + Bio = "Le meilleur Jazzman de France", + Class = 2 + }, + new + { + Name = "Armure", + Bio = "Solide", + Class = 6 + }); + }); + + modelBuilder.Entity("Entities.LargeImageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Base64") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("largeimages"); + + b.HasData( + new + { + Id = new Guid("70d7aace-13a9-40e1-bd94-99790805f6d0"), + Base64 = "aaa" + }); + }); + + modelBuilder.Entity("Entities.RuneEntity", b => + { + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("ImageId") + .HasColumnType("TEXT"); + + b.Property("RuneFamily") + .HasColumnType("INTEGER"); + + b.HasKey("Name"); + + b.HasIndex("ImageId"); + + b.ToTable("runes"); + + b.HasData( + new + { + Name = "Bullseye", + Description = "Steady shot", + RuneFamily = 1 + }, + new + { + Name = "Alkatraz", + Description = "Lock effect", + RuneFamily = 2 + }); + }); + + modelBuilder.Entity("Entities.RunePageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("runepages"); + + b.HasData( + new + { + Id = new Guid("a5a4f69b-5cbb-48c1-beb4-896bc9171714"), + Name = "Runepage_1" + }); + }); + + modelBuilder.Entity("Entities.RunePageRuneEntity", b => + { + b.Property("runepagesId") + .HasColumnType("TEXT"); + + b.Property("runesName") + .HasColumnType("TEXT"); + + b.Property("Category") + .HasColumnType("INTEGER"); + + b.HasKey("runepagesId", "runesName"); + + b.HasIndex("runesName"); + + b.ToTable("RunePageRuneEntity"); + }); + + modelBuilder.Entity("Entities.SkillEntity", b => + { + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("SkillType") + .HasColumnType("INTEGER"); + + b.HasKey("Name"); + + b.ToTable("skills"); + + b.HasData( + new + { + Name = "Boule de feu", + Description = "Fire!", + SkillType = 1 + }, + new + { + Name = "White Star", + Description = "Random damage", + SkillType = 3 + }); + }); + + modelBuilder.Entity("Entities.SkinEntity", b => + { + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("ChampionForeignKey") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ImageId") + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("REAL"); + + b.HasKey("Name"); + + b.HasIndex("ChampionForeignKey"); + + b.HasIndex("ImageId"); + + b.ToTable("skins"); + + b.HasData( + new + { + Name = "Dave de glace", + ChampionForeignKey = "Dave", + Description = "Enneigé", + Icon = "aaa", + Price = 7.99f + }, + new + { + Name = "Armure Fullspeed", + ChampionForeignKey = "Armure", + Description = "Deja vu", + Icon = "aaa", + Price = 9.99f + }); + }); + + modelBuilder.Entity("ChampionEntitySkillEntity", b => + { + b.HasOne("Entities.ChampionEntity", null) + .WithMany() + .HasForeignKey("ChampionsName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.SkillEntity", null) + .WithMany() + .HasForeignKey("SkillsName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entities.ChampionEntity", b => + { + b.HasOne("Entities.LargeImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageId"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("Entities.RuneEntity", b => + { + b.HasOne("Entities.LargeImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageId"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("Entities.RunePageRuneEntity", b => + { + b.HasOne("Entities.RunePageEntity", null) + .WithMany() + .HasForeignKey("runepagesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.RuneEntity", null) + .WithMany() + .HasForeignKey("runesName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entities.SkinEntity", b => + { + b.HasOne("Entities.ChampionEntity", "Champion") + .WithMany() + .HasForeignKey("ChampionForeignKey") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.LargeImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageId"); + + b.Navigation("Champion"); + + b.Navigation("Image"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/EntityFramework_LoL/Sources/Entities/Program.cs b/EntityFramework_LoL/Sources/Entities/Program.cs new file mode 100644 index 0000000..6e4348a --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/Program.cs @@ -0,0 +1,16 @@ +using Entities; +using Shared; + +ChampionEntity imri = new() +{ + Name = "Imri Cartel", + Bio = "Fou Furieux", + Class = ChampionClass.Assassin +}; +using (var context = new ChampionDbContext()) +{ + // Crée des nounours et les insère dans la base + Console.WriteLine("Creates and inserts new Champion"); + context.Add(imri); + context.SaveChanges(); +} diff --git a/EntityFramework_LoL/Sources/Entities/RuneEntity.cs b/EntityFramework_LoL/Sources/Entities/RuneEntity.cs new file mode 100644 index 0000000..9b1d077 --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/RuneEntity.cs @@ -0,0 +1,32 @@ +using Shared; +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 Entities +{ + public class RuneEntity + { + [Key] + [MaxLength(256)] + public string Name { get; set; } + + [Required] + [MaxLength(500)] + public string Description { get; set; } + + [Required] + public RuneFamily RuneFamily { get; set; } + public ICollection? runepages { get; set; } + + public Guid? ImageId { get; set; } + + [ForeignKey("ImageId")] + public LargeImageEntity? Image { get; set; } + + } +} diff --git a/EntityFramework_LoL/Sources/Entities/RunePageEntity.cs b/EntityFramework_LoL/Sources/Entities/RunePageEntity.cs new file mode 100644 index 0000000..ce2ae88 --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/RunePageEntity.cs @@ -0,0 +1,24 @@ +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 Entities +{ + public class RunePageEntity + { + + [Key] + public Guid Id { get; set; } + + [MaxLength(256)] + public string Name { get; set; } + + public ICollection runes { get; set; } + + + } +} diff --git a/EntityFramework_LoL/Sources/Entities/RunePageRuneEntity.cs b/EntityFramework_LoL/Sources/Entities/RunePageRuneEntity.cs new file mode 100644 index 0000000..a1ad83f --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/RunePageRuneEntity.cs @@ -0,0 +1,14 @@ +using Shared; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Entities +{ + public class RunePageRuneEntity + { + public Category Category { get; set; } + } +} diff --git a/EntityFramework_LoL/Sources/Entities/SkillEntity.cs b/EntityFramework_LoL/Sources/Entities/SkillEntity.cs new file mode 100644 index 0000000..51a4ffd --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/SkillEntity.cs @@ -0,0 +1,29 @@ +using Shared; +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 Entities +{ + public class SkillEntity + { + [Key] + [MaxLength(256)] + public string Name { get; set; } + + [Required] + [MaxLength(500)] + public string Description { get; set; } + + [Required] + public SkillType SkillType { get; set; } + + public virtual ICollection? Champions { get; set; } + + + } +} diff --git a/EntityFramework_LoL/Sources/Entities/SkinEntity.cs b/EntityFramework_LoL/Sources/Entities/SkinEntity.cs new file mode 100644 index 0000000..927dca3 --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/SkinEntity.cs @@ -0,0 +1,37 @@ +using Shared; +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 Entities +{ + public class SkinEntity + { + [Key] + [MaxLength(256)] + public string Name { get; set; } + [Required] + [MaxLength(500)] + public string Description { get; set; } + [Required] + public string Icon { get; set; } + [Required] + public float Price { get; set; } + + [Required] + public string ChampionForeignKey { get; set; } + + [ForeignKey("ChampionForeignKey")] + public ChampionEntity Champion { get; set; } + + public Guid? ImageId { get; set; } + + [ForeignKey("ImageId")] + public LargeImageEntity? Image { get; set; } + + } +} diff --git a/EntityFramework_LoL/Sources/EntityFramework/DbContexts/ChampionDbContext.cs b/EntityFramework_LoL/Sources/EntityFramework/DbContexts/ChampionDbContext.cs new file mode 100644 index 0000000..532648c --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/DbContexts/ChampionDbContext.cs @@ -0,0 +1,19 @@ +using EntityFramework.Entities; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EntityFramework.DbContexts +{ + internal class ChampionDbContext : DbContext + { + public DbSet champions { get; set; } + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlite($"Data Source=EntityFramework.Champions.db"); + } + } +} diff --git a/EntityFramework_LoL/Sources/EntityFramework/Entities/ChampionEntity.cs b/EntityFramework_LoL/Sources/EntityFramework/Entities/ChampionEntity.cs new file mode 100644 index 0000000..631bfca --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/Entities/ChampionEntity.cs @@ -0,0 +1,17 @@ +using System.ComponentModel.DataAnnotations; + +namespace EntityFramework.Entities +{ + internal class ChampionEntity + { + [Key] + [MaxLength(256)] + public string Name { get; set; } + [Required] + [MaxLength(500)] + public string Bio { get; set; } + [Required] + public string Icon { get; set; } + + } +} diff --git a/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db new file mode 100644 index 0000000..2643996 Binary files /dev/null and b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db differ diff --git a/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db-shm b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db-shm new file mode 100644 index 0000000..fe9ac28 Binary files /dev/null and b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db-shm differ diff --git a/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db-wal b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db-wal new file mode 100644 index 0000000..e531c0b Binary files /dev/null and b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db-wal differ diff --git a/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.csproj b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.csproj new file mode 100644 index 0000000..95f8b96 --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.csproj @@ -0,0 +1,30 @@ + + + + Exe + net6.0 + enable + enable + $(MSBuildProjectDirectory) + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230201154310_migr.Designer.cs b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230201154310_migr.Designer.cs new file mode 100644 index 0000000..7d92db0 --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230201154310_migr.Designer.cs @@ -0,0 +1,44 @@ +// +using EntityFramework.DbContexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EntityFramework.Migrations +{ + [DbContext(typeof(ChampionDbContext))] + [Migration("20230201154310_migr")] + partial class migr + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFramework.Entities.ChampionEntity", b => + { + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("Bio") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("champions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230201154310_migr.cs b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230201154310_migr.cs new file mode 100644 index 0000000..adfed99 --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230201154310_migr.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EntityFramework.Migrations +{ + /// + public partial class migr : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "champions", + columns: table => new + { + Name = table.Column(type: "TEXT", maxLength: 256, nullable: false), + Bio = table.Column(type: "TEXT", maxLength: 500, nullable: false), + Icon = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_champions", x => x.Name); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "champions"); + } + } +} diff --git a/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230209124258_myFirstMigration.Designer.cs b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230209124258_myFirstMigration.Designer.cs new file mode 100644 index 0000000..b64a1d8 --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230209124258_myFirstMigration.Designer.cs @@ -0,0 +1,44 @@ +// +using EntityFramework.DbContexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EntityFramework.Migrations +{ + [DbContext(typeof(ChampionDbContext))] + [Migration("20230209124258_myFirstMigration")] + partial class myFirstMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFramework.Entities.ChampionEntity", b => + { + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("Bio") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("champions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230209124258_myFirstMigration.cs b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230209124258_myFirstMigration.cs new file mode 100644 index 0000000..9f3f929 --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230209124258_myFirstMigration.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EntityFramework.Migrations +{ + /// + public partial class myFirstMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/EntityFramework_LoL/Sources/EntityFramework/Migrations/ChampionDbContextModelSnapshot.cs b/EntityFramework_LoL/Sources/EntityFramework/Migrations/ChampionDbContextModelSnapshot.cs new file mode 100644 index 0000000..171949d --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/Migrations/ChampionDbContextModelSnapshot.cs @@ -0,0 +1,41 @@ +// +using EntityFramework.DbContexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EntityFramework.Migrations +{ + [DbContext(typeof(ChampionDbContext))] + partial class ChampionDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFramework.Entities.ChampionEntity", b => + { + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("Bio") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("champions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/EntityFramework_LoL/Sources/EntityFramework/Program.cs b/EntityFramework_LoL/Sources/EntityFramework/Program.cs new file mode 100644 index 0000000..8772279 --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/Program.cs @@ -0,0 +1,17 @@ +using EntityFramework.DbContexts; +using EntityFramework.Entities; +using Model; + +ChampionEntity dave = new ChampionEntity() +{ + Name = "Dave", + Bio = "Le meilleur Jazzman de France", + Icon = "aaa" +}; +using (var context = new ChampionDbContext()) +{ + // Crée des nounours et les insère dans la base + Console.WriteLine("Creates and inserts new Champion"); + context.Add(dave); + context.SaveChanges(); +} diff --git a/EntityFramework_LoL/Sources/LeagueOfLegends.sln b/EntityFramework_LoL/Sources/LeagueOfLegends.sln index db008a1..5e32aeb 100644 --- a/EntityFramework_LoL/Sources/LeagueOfLegends.sln +++ b/EntityFramework_LoL/Sources/LeagueOfLegends.sln @@ -17,7 +17,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubLib", "StubLib\StubLib. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API_LoL_Project", "API_LoL_Project\API_LoL_Project.csproj", "{4EDC93E0-35B8-4EF1-9318-24F7A606BA97}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DTO", "DTO\DTO.csproj", "{7F6A519E-98F8-429E-B34F-9B0D20075CFB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{7F6A519E-98F8-429E-B34F-9B0D20075CFB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Entity Framework", "Entity Framework", "{BC2FFCA4-3801-433F-A83E-B55345F3B31E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entities", "Entities\Entities.csproj", "{C463E2E1-237A-4339-A4C4-6EA3BE7002AE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -49,6 +53,10 @@ Global {7F6A519E-98F8-429E-B34F-9B0D20075CFB}.Debug|Any CPU.Build.0 = Debug|Any CPU {7F6A519E-98F8-429E-B34F-9B0D20075CFB}.Release|Any CPU.ActiveCfg = Release|Any CPU {7F6A519E-98F8-429E-B34F-9B0D20075CFB}.Release|Any CPU.Build.0 = Release|Any CPU + {C463E2E1-237A-4339-A4C4-6EA3BE7002AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C463E2E1-237A-4339-A4C4-6EA3BE7002AE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C463E2E1-237A-4339-A4C4-6EA3BE7002AE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C463E2E1-237A-4339-A4C4-6EA3BE7002AE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -56,6 +64,7 @@ Global GlobalSection(NestedProjects) = preSolution {1889FA6E-B7C6-416E-8628-9449FB9070B9} = {C76D0C23-1FFA-4963-93CD-E12BD643F030} {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {2C607793-B163-4731-A4D1-AFE8A7C4C170} + {C463E2E1-237A-4339-A4C4-6EA3BE7002AE} = {BC2FFCA4-3801-433F-A83E-B55345F3B31E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9} diff --git a/EntityFramework_LoL/Sources/Model/Champion.cs b/EntityFramework_LoL/Sources/Model/Champion.cs index fd4a5ca..9b7e96d 100644 --- a/EntityFramework_LoL/Sources/Model/Champion.cs +++ b/EntityFramework_LoL/Sources/Model/Champion.cs @@ -1,4 +1,5 @@ -using System.Collections.Immutable; +using Shared; +using System.Collections.Immutable; using System.Collections.ObjectModel; using System.Numerics; using System.Text; diff --git a/EntityFramework_LoL/Sources/Model/Model.csproj b/EntityFramework_LoL/Sources/Model/Model.csproj index 89f6363..53e6be4 100644 --- a/EntityFramework_LoL/Sources/Model/Model.csproj +++ b/EntityFramework_LoL/Sources/Model/Model.csproj @@ -9,9 +9,6 @@ - - - diff --git a/EntityFramework_LoL/Sources/Model/Rune.cs b/EntityFramework_LoL/Sources/Model/Rune.cs index 7b5047b..368582a 100644 --- a/EntityFramework_LoL/Sources/Model/Rune.cs +++ b/EntityFramework_LoL/Sources/Model/Rune.cs @@ -1,4 +1,4 @@ -using System; +using Shared; namespace Model { diff --git a/EntityFramework_LoL/Sources/Model/RunePage.cs b/EntityFramework_LoL/Sources/Model/RunePage.cs index cf56628..0dbb7ab 100644 --- a/EntityFramework_LoL/Sources/Model/RunePage.cs +++ b/EntityFramework_LoL/Sources/Model/RunePage.cs @@ -1,4 +1,4 @@ -using System; +using Shared; using System.Collections.ObjectModel; namespace Model diff --git a/EntityFramework_LoL/Sources/Model/Skill.cs b/EntityFramework_LoL/Sources/Model/Skill.cs index 0679ea6..16f947e 100644 --- a/EntityFramework_LoL/Sources/Model/Skill.cs +++ b/EntityFramework_LoL/Sources/Model/Skill.cs @@ -1,4 +1,4 @@ -using System; +using Shared; namespace Model { diff --git a/EntityFramework_LoL/Sources/Model/enums/ChampionClass.cs b/EntityFramework_LoL/Sources/Shared/enums/ChampionClass.cs similarity index 77% rename from EntityFramework_LoL/Sources/Model/enums/ChampionClass.cs rename to EntityFramework_LoL/Sources/Shared/enums/ChampionClass.cs index d169512..701b297 100644 --- a/EntityFramework_LoL/Sources/Model/enums/ChampionClass.cs +++ b/EntityFramework_LoL/Sources/Shared/enums/ChampionClass.cs @@ -1,5 +1,4 @@ -using System; -namespace Model +namespace Shared { public enum ChampionClass { diff --git a/EntityFramework_LoL/Sources/Model/enums/RuneFamily.cs b/EntityFramework_LoL/Sources/Shared/enums/RuneFamily.cs similarity index 68% rename from EntityFramework_LoL/Sources/Model/enums/RuneFamily.cs rename to EntityFramework_LoL/Sources/Shared/enums/RuneFamily.cs index 07a232c..b025487 100644 --- a/EntityFramework_LoL/Sources/Model/enums/RuneFamily.cs +++ b/EntityFramework_LoL/Sources/Shared/enums/RuneFamily.cs @@ -1,5 +1,4 @@ -using System; -namespace Model +namespace Shared { public enum RuneFamily { diff --git a/EntityFramework_LoL/Sources/Model/RunePage.Category.cs b/EntityFramework_LoL/Sources/Shared/enums/RunePage.Category.cs similarity index 60% rename from EntityFramework_LoL/Sources/Model/RunePage.Category.cs rename to EntityFramework_LoL/Sources/Shared/enums/RunePage.Category.cs index 1047c0e..2ee019d 100644 --- a/EntityFramework_LoL/Sources/Model/RunePage.Category.cs +++ b/EntityFramework_LoL/Sources/Shared/enums/RunePage.Category.cs @@ -1,8 +1,5 @@ -using System; -namespace Model +namespace Shared { - public partial class RunePage - { public enum Category { Major, @@ -12,6 +9,5 @@ namespace Model OtherMinor1, OtherMinor2 } - } } diff --git a/EntityFramework_LoL/Sources/Model/enums/SkillType.cs b/EntityFramework_LoL/Sources/Shared/enums/SkillType.cs similarity index 69% rename from EntityFramework_LoL/Sources/Model/enums/SkillType.cs rename to EntityFramework_LoL/Sources/Shared/enums/SkillType.cs index d7fc8da..3e48028 100644 --- a/EntityFramework_LoL/Sources/Model/enums/SkillType.cs +++ b/EntityFramework_LoL/Sources/Shared/enums/SkillType.cs @@ -1,5 +1,4 @@ -using System; -namespace Model +namespace Shared { public enum SkillType { diff --git a/EntityFramework_LoL/Sources/Stub/Program.cs b/EntityFramework_LoL/Sources/Stub/Program.cs new file mode 100644 index 0000000..9c2e3c3 --- /dev/null +++ b/EntityFramework_LoL/Sources/Stub/Program.cs @@ -0,0 +1,15 @@ +using Entities; + +ChampionEntity dave = new() +{ + Name = "Dave", + Bio = "Le meilleur Jazzman de France", + Icon = "aaa" +}; +using (var context = new ChampionDbContext()) +{ + // Crée des nounours et les insère dans la base + Console.WriteLine("Creates and inserts new Champion"); + context.Add(dave); + context.SaveChanges(); +} diff --git a/EntityFramework_LoL/Sources/Stub/Stub.csproj b/EntityFramework_LoL/Sources/Stub/Stub.csproj new file mode 100644 index 0000000..36bc2be --- /dev/null +++ b/EntityFramework_LoL/Sources/Stub/Stub.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + enable + $(MSBuildProjectDirectory) + + + + + + + diff --git a/EntityFramework_LoL/Sources/StubLib/StubData.Champions.cs b/EntityFramework_LoL/Sources/StubLib/StubData.Champions.cs index ad19275..8ed1220 100644 --- a/EntityFramework_LoL/Sources/StubLib/StubData.Champions.cs +++ b/EntityFramework_LoL/Sources/StubLib/StubData.Champions.cs @@ -1,5 +1,6 @@ using System; using Model; +using Shared; namespace StubLib { diff --git a/EntityFramework_LoL/Sources/StubLib/StubData.RunePages.cs b/EntityFramework_LoL/Sources/StubLib/StubData.RunePages.cs index a08a947..169a102 100644 --- a/EntityFramework_LoL/Sources/StubLib/StubData.RunePages.cs +++ b/EntityFramework_LoL/Sources/StubLib/StubData.RunePages.cs @@ -1,5 +1,6 @@ using System; using Model; +using Shared; namespace StubLib { @@ -10,12 +11,12 @@ namespace StubLib private void InitRunePages() { var runePage1 = new RunePage("rune page 1"); - runePage1[RunePage.Category.Major] = runes[0]; - runePage1[RunePage.Category.Minor1] = runes[1]; - runePage1[RunePage.Category.Minor2] = runes[2]; - runePage1[RunePage.Category.Minor3] = runes[3]; - runePage1[RunePage.Category.OtherMinor1] = runes[4]; - runePage1[RunePage.Category.OtherMinor2] = runes[5]; + runePage1[Category.Major] = runes[0]; + runePage1[Category.Minor1] = runes[1]; + runePage1[Category.Minor2] = runes[2]; + runePage1[Category.Minor3] = runes[3]; + runePage1[Category.OtherMinor1] = runes[4]; + runePage1[Category.OtherMinor2] = runes[5]; runePages.Add(runePage1); } diff --git a/EntityFramework_LoL/Sources/StubLib/StubData.Runes.cs b/EntityFramework_LoL/Sources/StubLib/StubData.Runes.cs index f0e8802..32fce54 100644 --- a/EntityFramework_LoL/Sources/StubLib/StubData.Runes.cs +++ b/EntityFramework_LoL/Sources/StubLib/StubData.Runes.cs @@ -1,5 +1,6 @@ using System; using Model; +using Shared; namespace StubLib { diff --git a/EntityFramework_LoL/Sources/Tests/ConsoleTests/Program.cs b/EntityFramework_LoL/Sources/Tests/ConsoleTests/Program.cs index 93e266f..d642ce2 100644 --- a/EntityFramework_LoL/Sources/Tests/ConsoleTests/Program.cs +++ b/EntityFramework_LoL/Sources/Tests/ConsoleTests/Program.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using Microsoft.Extensions.DependencyInjection; using Model; +using Shared; using StubLib; using static System.Console;