Merge pull request 'Arthur_EF' (#1) from Arthur_EF into master

Reviewed-on: #1
David_next_step
David D'ALMEIDA 2 years ago
commit cbb4e95f57

@ -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<SkinEntity> skins { get; set; }
public DbSet<ChampionEntity> champions { get; set; }
public DbSet<SkillEntity> skills { get; set; }
public DbSet<RuneEntity> runes { get; set; }
public DbSet<RunePageEntity> runepages { get; set; }
public DbSet<LargeImageEntity> largeimages { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite($"Data Source=Entities.Champions.db");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<LargeImageEntity>().Property(e => e.Id).ValueGeneratedOnAdd();
modelBuilder.Entity<RunePageEntity>().Property(e => e.Id).ValueGeneratedOnAdd();
modelBuilder.Entity<RunePageEntity>()
.HasMany(x => x.runes)
.WithMany(x => x.runepages)
.UsingEntity<RunePageRuneEntity>();
modelBuilder.Entity<LargeImageEntity>().HasData(new List<LargeImageEntity>()
{
new()
{
Id = Guid.NewGuid(),
Base64 = "aaa"
}
});
modelBuilder.Entity<ChampionEntity>().HasData(new List<ChampionEntity>() {
new()
{
Name = "Dave",
Bio = "Le meilleur Jazzman de France",
Class = ChampionClass.Fighter,
},
new()
{
Name = "Armure",
Bio = "Solide",
Class = ChampionClass.Tank,
}
});
modelBuilder.Entity<SkinEntity>().HasData(new List<SkinEntity>() {
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<SkillEntity>().HasData(new List<SkillEntity>() {
new()
{
Name = "Boule de feu",
Description = "Fire!",
SkillType = SkillType.Basic
},
new()
{
Name = "White Star",
Description = "Random damage",
SkillType = SkillType.Ultimate
}
});
modelBuilder.Entity<RunePageEntity>().HasData(new List<RunePageEntity>()
{
new()
{
Id = Guid.NewGuid(),
Name="Runepage_1"
}
});
modelBuilder.Entity<RuneEntity>().HasData(new List<RuneEntity>() {
new()
{
Name = "Bullseye",
Description = "Steady shot",
RuneFamily = RuneFamily.Precision
},
new()
{
Name = "Alkatraz",
Description = "Lock effect",
RuneFamily = RuneFamily.Domination
}
});
}
}
}

@ -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<SkillEntity>? Skills { get; set; }
public Guid? ImageId { get; set; }
[ForeignKey("ImageId")]
public LargeImageEntity? Image { get; set; }
}
}

@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<StartWorkingDirectory>$(MSBuildProjectDirectory)</StartWorkingDirectory>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Programme.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>

@ -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; }
}
}

@ -0,0 +1,332 @@
// <auto-generated />
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
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("ChampionEntitySkillEntity", b =>
{
b.Property<string>("ChampionsName")
.HasColumnType("TEXT");
b.Property<string>("SkillsName")
.HasColumnType("TEXT");
b.HasKey("ChampionsName", "SkillsName");
b.HasIndex("SkillsName");
b.ToTable("ChampionEntitySkillEntity");
});
modelBuilder.Entity("Entities.ChampionEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.HasColumnType("TEXT");
b.Property<Guid?>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("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<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<Guid?>("ImageId")
.HasColumnType("TEXT");
b.Property<int>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("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<Guid>("runepagesId")
.HasColumnType("TEXT");
b.Property<string>("runesName")
.HasColumnType("TEXT");
b.Property<int>("Category")
.HasColumnType("INTEGER");
b.HasKey("runepagesId", "runesName");
b.HasIndex("runesName");
b.ToTable("RunePageRuneEntity");
});
modelBuilder.Entity("Entities.SkillEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<int>("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<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("ChampionForeignKey")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<Guid?>("ImageId")
.HasColumnType("TEXT");
b.Property<float>("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
}
}
}

@ -0,0 +1,273 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace Entities.Migrations
{
/// <inheritdoc />
public partial class myFirstMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "largeimages",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Base64 = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_largeimages", x => x.Id);
});
migrationBuilder.CreateTable(
name: "runepages",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Name = table.Column<string>(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<string>(type: "TEXT", maxLength: 256, nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
SkillType = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_skills", x => x.Name);
});
migrationBuilder.CreateTable(
name: "champions",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
Bio = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: true),
Class = table.Column<int>(type: "INTEGER", nullable: false),
ImageId = table.Column<Guid>(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<string>(type: "TEXT", maxLength: 256, nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
RuneFamily = table.Column<int>(type: "INTEGER", nullable: false),
ImageId = table.Column<Guid>(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<string>(type: "TEXT", nullable: false),
SkillsName = table.Column<string>(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<string>(type: "TEXT", maxLength: 256, nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false),
Price = table.Column<float>(type: "REAL", nullable: false),
ChampionForeignKey = table.Column<string>(type: "TEXT", nullable: false),
ImageId = table.Column<Guid>(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<Guid>(type: "TEXT", nullable: false),
runesName = table.Column<string>(type: "TEXT", nullable: false),
Category = table.Column<int>(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");
}
/// <inheritdoc />
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");
}
}
}

@ -0,0 +1,329 @@
// <auto-generated />
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<string>("ChampionsName")
.HasColumnType("TEXT");
b.Property<string>("SkillsName")
.HasColumnType("TEXT");
b.HasKey("ChampionsName", "SkillsName");
b.HasIndex("SkillsName");
b.ToTable("ChampionEntitySkillEntity");
});
modelBuilder.Entity("Entities.ChampionEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.HasColumnType("TEXT");
b.Property<Guid?>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("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<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<Guid?>("ImageId")
.HasColumnType("TEXT");
b.Property<int>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("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<Guid>("runepagesId")
.HasColumnType("TEXT");
b.Property<string>("runesName")
.HasColumnType("TEXT");
b.Property<int>("Category")
.HasColumnType("INTEGER");
b.HasKey("runepagesId", "runesName");
b.HasIndex("runesName");
b.ToTable("RunePageRuneEntity");
});
modelBuilder.Entity("Entities.SkillEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<int>("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<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("ChampionForeignKey")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<Guid?>("ImageId")
.HasColumnType("TEXT");
b.Property<float>("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
}
}
}

@ -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();
}

@ -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<RunePageEntity>? runepages { get; set; }
public Guid? ImageId { get; set; }
[ForeignKey("ImageId")]
public LargeImageEntity? Image { get; set; }
}
}

@ -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<RuneEntity> runes { get; set; }
}
}

@ -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; }
}
}

@ -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<ChampionEntity>? Champions { get; set; }
}
}

@ -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; }
}
}

@ -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<ChampionEntity> champions { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite($"Data Source=EntityFramework.Champions.db");
}
}
}

@ -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; }
}
}

@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<StartWorkingDirectory>$(MSBuildProjectDirectory)</StartWorkingDirectory>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,44 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("champions");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,34 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFramework.Migrations
{
/// <inheritdoc />
public partial class migr : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "champions",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
Bio = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_champions", x => x.Name);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "champions");
}
}
}

@ -0,0 +1,44 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("champions");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFramework.Migrations
{
/// <inheritdoc />
public partial class myFirstMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

@ -0,0 +1,41 @@
// <auto-generated />
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<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("champions");
});
#pragma warning restore 612, 618
}
}
}

@ -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();
}

@ -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}

@ -1,4 +1,5 @@
using System.Collections.Immutable;
using Shared;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.Numerics;
using System.Text;

@ -9,9 +9,6 @@
<ItemGroup>
<None Remove="enums\" />
</ItemGroup>
<ItemGroup>
<Folder Include="enums\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\Shared.csproj" />
</ItemGroup>

@ -1,4 +1,4 @@
using System;
using Shared;
namespace Model
{

@ -1,4 +1,4 @@
using System;
using Shared;
using System.Collections.ObjectModel;
namespace Model

@ -1,4 +1,4 @@
using System;
using Shared;
namespace Model
{

@ -1,5 +1,4 @@
using System;
namespace Model
namespace Shared
{
public enum ChampionClass
{

@ -1,5 +1,4 @@
using System;
namespace Model
namespace Shared
{
public enum RuneFamily
{

@ -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
}
}
}

@ -1,5 +1,4 @@
using System;
namespace Model
namespace Shared
{
public enum SkillType
{

@ -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();
}

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<StartWorkingDirectory>$(MSBuildProjectDirectory)</StartWorkingDirectory>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Entities\Entities.csproj" />
</ItemGroup>
</Project>

@ -1,5 +1,6 @@
using System;
using Model;
using Shared;
namespace StubLib
{

@ -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);
}

@ -1,5 +1,6 @@
using System;
using Model;
using Shared;
namespace StubLib
{

@ -2,6 +2,7 @@
using System.Diagnostics;
using Microsoft.Extensions.DependencyInjection;
using Model;
using Shared;
using StubLib;
using static System.Console;

Loading…
Cancel
Save