Rune et image fait

master
Jolys Enzo 2 years ago
parent aa57c35e5f
commit cf2ed59a22

@ -9,17 +9,17 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Api_lol.Factories; using Api_lol.Factories;
using Api_lol.Controllers;
namespace Client namespace Client
{ {
public class StubEntityInit public class StubEntityInit
{ {
private Factories facto = new Factories(); private Factories facto = new Factories();
private StubData data = new StubData();
public async void AddAllChampions() public async void AddAllChampions()
{ {
StubData data = new StubData();
var liste = await data.ChampionsMgr.GetItems(0,await data.ChampionsMgr.GetNbItems()); var liste = await data.ChampionsMgr.GetItems(0,await data.ChampionsMgr.GetNbItems());
var listeDto = liste.ToList().Select(model => facto.ChampionModelToEntity(model)); var listeDto = liste.ToList().Select(model => facto.ChampionModelToEntity(model));
@ -27,6 +27,8 @@ namespace Client
{ {
foreach(var item in listeDto) foreach(var item in listeDto)
{ {
int ImageId = AddOneImage();
item.ImageId = ImageId;
db.Add(item); db.Add(item);
} }
db.SaveChanges(); db.SaveChanges();
@ -35,9 +37,7 @@ namespace Client
public async void AddAllSkins() public async void AddAllSkins()
{ {
StubData data = new StubData();
var skins = await data.SkinsMgr.GetItems(0, await data.SkinsMgr.GetNbItems()); var skins = await data.SkinsMgr.GetItems(0, await data.SkinsMgr.GetNbItems());
//var skinsDto = skins.ToList().Select(model => facto.SkinsModelToEntity(model));
using (BDDContext db = new BDDContext()) using (BDDContext db = new BDDContext())
{ {
@ -45,17 +45,59 @@ namespace Client
{ {
int idChampion = (db.Champions.Where(m => m.Name == item.Champion.Name).First()).Id; int idChampion = (db.Champions.Where(m => m.Name == item.Champion.Name).First()).Id;
EntitySkins skin = facto.SkinsModelToEntity(item,idChampion); EntitySkins skin = facto.SkinsModelToEntity(item,idChampion);
int idImage = AddOneImage();
skin.ImageId = idImage;
db.Add(skin); db.Add(skin);
} }
db.SaveChanges(); db.SaveChanges();
} }
} }
public int AddOneImage()
{
Random aleatoire = new Random();
EntityLargeImage tmpImage = new EntityLargeImage();
tmpImage.Base64 = "Inconnu";
tmpImage.Id = aleatoire.Next();
using (BDDContext db = new BDDContext())
{
db.Add(tmpImage);
db.SaveChanges();
}
return tmpImage.Id;
}
public async void AddAllRunes()
{
var runes = await data.RunesMgr.GetItems(0, await data.RunesMgr.GetNbItems());
using (BDDContext db = new BDDContext())
{
foreach (var item in runes)
{
EntityRunes rune = facto.RuneModelToEntity(item);
int idImage = AddOneImage();
rune.ImageId = idImage;
db.Add(rune);
}
db.SaveChanges();
}
}
public void Init() public void Init()
{ {
//Image en même temps que champion,rune,Skin
//Champion
AddAllChampions(); AddAllChampions();
//Skin
AddAllSkins(); AddAllSkins();
//Rune
AddAllRunes();
} }
} }
} }

@ -24,10 +24,6 @@ namespace EntityFramwork
.HasMany(e => e.Skins) .HasMany(e => e.Skins)
.WithOne(e => e.Champion) .WithOne(e => e.Champion)
.HasForeignKey(e => e.ChampionForeignKey); .HasForeignKey(e => e.ChampionForeignKey);
//Clé avec Images
modelBuilder.Entity<EntityChampions>().HasOne(n => n.Image)
.WithOne(c => c.Champion)
.HasForeignKey<EntityLargeImage>(c => c.Champion);
// -------------------------------------------------------------------------------// // -------------------------------------------------------------------------------//
//création de la table Skins //création de la table Skins
modelBuilder.Entity<EntitySkins>().HasKey(m => m.Id); modelBuilder.Entity<EntitySkins>().HasKey(m => m.Id);
@ -44,13 +40,32 @@ namespace EntityFramwork
modelBuilder.Entity<EntityLargeImage>().HasKey(c => c.Id); modelBuilder.Entity<EntityLargeImage>().HasKey(c => c.Id);
modelBuilder.Entity<EntityLargeImage>().Property(c => c.Id) modelBuilder.Entity<EntityLargeImage>().Property(c => c.Id)
.ValueGeneratedOnAdd(); .ValueGeneratedOnAdd();
//Relation Images et Champion
modelBuilder.Entity<EntityLargeImage>()
.HasOne(e => e.Champion)
.WithOne(z => z.Image)
.HasForeignKey<EntityChampions>(x => x.ImageId);
//Relation Images et Skins
modelBuilder.Entity<EntityLargeImage>()
.HasOne(e => e.Skin)
.WithOne(z => z.Image)
.HasForeignKey<EntitySkins>(x => x.ImageId);
//Relation Images et Rune
modelBuilder.Entity<EntityLargeImage>()
.HasOne(e => e.Rune)
.WithOne(z => z.Image)
.HasForeignKey<EntityRunes>(x => x.ImageId);
// -------------------------------------------------------------------------------//
//création de la table Runes
modelBuilder.Entity<EntityRunes>().HasKey(c => c.Id);
modelBuilder.Entity<EntityRunes>().Property(c => c.Id)
.ValueGeneratedOnAdd();
} }
public DbSet<EntityChampions> Champions { get; set; } public DbSet<EntityChampions> Champions { get; set; }
public DbSet<EntitySkins> Skins { get; set; } public DbSet<EntitySkins> Skins { get; set; }
public DbSet<EntityLargeImage> Images { get; set; } public DbSet<EntityLargeImage> Images { get; set; }
public DbSet<EntityRunes> Runes { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {

@ -17,9 +17,13 @@ namespace DTO
public string Bio { get; set; } public string Bio { get; set; }
public string Icon { get; set; } public string Icon { get; set; }
public string Classe { get; set; }
// ----------------- Skin -----------------------//
public List<EntitySkins> Skins { get; set; } public List<EntitySkins> Skins { get; set; }
// ----------------- Image -----------------------//
public int ImageId { get; set; }
public EntityLargeImage Image { get; set; } public EntityLargeImage Image { get; set; }
} }

@ -13,6 +13,12 @@ namespace EntityFramwork
public string Base64 { get; set; } public string Base64 { get; set; }
// --------- Champion ------------ //
public EntityChampions Champion { get; set; } public EntityChampions Champion { get; set; }
// --------- Skin ------------ //
public EntitySkins Skin { get; set; }
// --------- Rune ------------ //
public EntityRunes Rune { get; set; }
} }
} }

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EntityFramwork
{
public class EntityRunePage
{
public int Id { get; set; }
public string Name { get; set; }
}
}

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EntityFramwork
{
public class EntityRunes
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Icon { get; set; }
public string Family { get; set; }
// --------- Images ---------- //
public int ImageId { get; set; }
public EntityLargeImage Image { get; set; }
}
}

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EntityFramwork
{
public class EntitySkill
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Type { get; set; }
}
}

@ -19,9 +19,13 @@ namespace EntityFramwork
public float Price { get; set; } public float Price { get; set; }
// ----------- Champion ----------- //
public int ChampionForeignKey { get; set; } public int ChampionForeignKey { get; set; }
[ForeignKey("ChampionForeignKey")] [ForeignKey("ChampionForeignKey")]
public EntityChampions Champion { get; set; } public EntityChampions Champion { get; set; }
// ----------- Image ------------ //
public int ImageId { get; set; }
public EntityLargeImage Image { get; set; }
} }
} }

@ -12,6 +12,7 @@ namespace EntityFramwork.Factories
entity.Name = champ.Name; entity.Name = champ.Name;
entity.Bio = champ.Bio; entity.Bio = champ.Bio;
entity.Icon = champ.Icon; entity.Icon = champ.Icon;
entity.Classe = champ.Class.ToString();
return entity; return entity;
} }
@ -24,7 +25,29 @@ namespace EntityFramwork.Factories
entity.Icon = skin.Icon; entity.Icon = skin.Icon;
entity.Description = skin.Description; entity.Description = skin.Description;
entity.ChampionForeignKey = id; entity.ChampionForeignKey = id;
//entity.Champion = ChampionModelToEntity(skin.Champion);
return entity;
}
public EntityRunes RuneModelToEntity(Rune rune)
{
EntityRunes entity = new EntityRunes();
entity.Name= rune.Name;
entity.Icon= rune.Icon;
entity.Description = rune.Description;
entity.Family = rune.Family.ToString();
return entity;
}
public EntitySkill SkillModeleToEntity(Skill skill)
{
EntitySkill entity = new EntitySkill();
entity.Name = skill.Name;
entity.Description = skill.Description;
entity.Type = skill.Type.ToString();
return entity; return entity;
} }

@ -1,108 +0,0 @@
// <auto-generated />
using EntityFramwork;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFramwork.Migrations
{
[DbContext(typeof(BDDContext))]
[Migration("20230208121743_test")]
partial class test
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("DTO.EntityChampions", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Champions");
});
modelBuilder.Entity("EntityFramwork.EntityLargeImage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Base64")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Images");
});
modelBuilder.Entity("EntityFramwork.EntitySkins", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ChampionId")
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Price")
.HasColumnType("REAL");
b.HasKey("Id");
b.HasIndex("ChampionId");
b.ToTable("Skins");
});
modelBuilder.Entity("EntityFramwork.EntitySkins", b =>
{
b.HasOne("DTO.EntityChampions", "Champion")
.WithMany("Skins")
.HasForeignKey("ChampionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Champion");
});
modelBuilder.Entity("DTO.EntityChampions", b =>
{
b.Navigation("Skins");
});
#pragma warning restore 612, 618
}
}
}

@ -1,108 +0,0 @@
// <auto-generated />
using EntityFramwork;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFramwork.Migrations
{
[DbContext(typeof(BDDContext))]
[Migration("20230208121840_test2")]
partial class test2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("DTO.EntityChampions", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Champions");
});
modelBuilder.Entity("EntityFramwork.EntityLargeImage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Base64")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Images");
});
modelBuilder.Entity("EntityFramwork.EntitySkins", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ChampionId")
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Price")
.HasColumnType("REAL");
b.HasKey("Id");
b.HasIndex("ChampionId");
b.ToTable("Skins");
});
modelBuilder.Entity("EntityFramwork.EntitySkins", b =>
{
b.HasOne("DTO.EntityChampions", "Champion")
.WithMany("Skins")
.HasForeignKey("ChampionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Champion");
});
modelBuilder.Entity("DTO.EntityChampions", b =>
{
b.Navigation("Skins");
});
#pragma warning restore 612, 618
}
}
}

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

@ -1,62 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFramwork.Migrations
{
/// <inheritdoc />
public partial class test3 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Skins_Champions_ChampionId",
table: "Skins");
migrationBuilder.RenameColumn(
name: "ChampionId",
table: "Skins",
newName: "ChampionForeignKey");
migrationBuilder.RenameIndex(
name: "IX_Skins_ChampionId",
table: "Skins",
newName: "IX_Skins_ChampionForeignKey");
migrationBuilder.AddForeignKey(
name: "FK_Skins_Champions_ChampionForeignKey",
table: "Skins",
column: "ChampionForeignKey",
principalTable: "Champions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Skins_Champions_ChampionForeignKey",
table: "Skins");
migrationBuilder.RenameColumn(
name: "ChampionForeignKey",
table: "Skins",
newName: "ChampionId");
migrationBuilder.RenameIndex(
name: "IX_Skins_ChampionForeignKey",
table: "Skins",
newName: "IX_Skins_ChampionId");
migrationBuilder.AddForeignKey(
name: "FK_Skins_Champions_ChampionId",
table: "Skins",
column: "ChampionId",
principalTable: "Champions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

@ -10,8 +10,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace EntityFramwork.Migrations namespace EntityFramwork.Migrations
{ {
[DbContext(typeof(BDDContext))] [DbContext(typeof(BDDContext))]
[Migration("20230208135031_test3")] [Migration("20230208221227_test")]
partial class test3 partial class test
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -33,12 +33,18 @@ namespace EntityFramwork.Migrations
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("ImageId")
.HasColumnType("INTEGER");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ImageId")
.IsUnique();
b.HasIndex("Name") b.HasIndex("Name")
.IsUnique(); .IsUnique();
@ -47,7 +53,7 @@ namespace EntityFramwork.Migrations
modelBuilder.Entity("EntityFramwork.EntityLargeImage", b => modelBuilder.Entity("EntityFramwork.EntityLargeImage", b =>
{ {
b.Property<long>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
@ -60,6 +66,35 @@ namespace EntityFramwork.Migrations
b.ToTable("Images"); b.ToTable("Images");
}); });
modelBuilder.Entity("EntityFramwork.EntityRunes", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("ImageId")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("ImageId")
.IsUnique();
b.ToTable("Runes");
});
modelBuilder.Entity("EntityFramwork.EntitySkins", b => modelBuilder.Entity("EntityFramwork.EntitySkins", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -77,6 +112,9 @@ namespace EntityFramwork.Migrations
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("ImageId")
.HasColumnType("INTEGER");
b.Property<float>("Price") b.Property<float>("Price")
.HasColumnType("REAL"); .HasColumnType("REAL");
@ -84,9 +122,34 @@ namespace EntityFramwork.Migrations
b.HasIndex("ChampionForeignKey"); b.HasIndex("ChampionForeignKey");
b.HasIndex("ImageId")
.IsUnique();
b.ToTable("Skins"); b.ToTable("Skins");
}); });
modelBuilder.Entity("DTO.EntityChampions", b =>
{
b.HasOne("EntityFramwork.EntityLargeImage", "Image")
.WithOne("Champion")
.HasForeignKey("DTO.EntityChampions", "ImageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Image");
});
modelBuilder.Entity("EntityFramwork.EntityRunes", b =>
{
b.HasOne("EntityFramwork.EntityLargeImage", "Image")
.WithOne("Rune")
.HasForeignKey("EntityFramwork.EntityRunes", "ImageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Image");
});
modelBuilder.Entity("EntityFramwork.EntitySkins", b => modelBuilder.Entity("EntityFramwork.EntitySkins", b =>
{ {
b.HasOne("DTO.EntityChampions", "Champion") b.HasOne("DTO.EntityChampions", "Champion")
@ -95,13 +158,33 @@ namespace EntityFramwork.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("EntityFramwork.EntityLargeImage", "Image")
.WithOne("Skin")
.HasForeignKey("EntityFramwork.EntitySkins", "ImageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Champion"); b.Navigation("Champion");
b.Navigation("Image");
}); });
modelBuilder.Entity("DTO.EntityChampions", b => modelBuilder.Entity("DTO.EntityChampions", b =>
{ {
b.Navigation("Skins"); b.Navigation("Skins");
}); });
modelBuilder.Entity("EntityFramwork.EntityLargeImage", b =>
{
b.Navigation("Champion")
.IsRequired();
b.Navigation("Rune")
.IsRequired();
b.Navigation("Skin")
.IsRequired();
});
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }

@ -10,6 +10,19 @@ namespace EntityFramwork.Migrations
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.CreateTable(
name: "Images",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Base64 = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Images", x => x.Id);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Champions", name: "Champions",
columns: table => new columns: table => new
@ -18,24 +31,40 @@ namespace EntityFramwork.Migrations
.Annotation("Sqlite:Autoincrement", true), .Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false), Name = table.Column<string>(type: "TEXT", nullable: false),
Bio = table.Column<string>(type: "TEXT", nullable: false), Bio = table.Column<string>(type: "TEXT", nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false) Icon = table.Column<string>(type: "TEXT", nullable: false),
ImageId = table.Column<int>(type: "INTEGER", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Champions", x => x.Id); table.PrimaryKey("PK_Champions", x => x.Id);
table.ForeignKey(
name: "FK_Champions_Images_ImageId",
column: x => x.ImageId,
principalTable: "Images",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Images", name: "Runes",
columns: table => new columns: table => new
{ {
Id = table.Column<long>(type: "INTEGER", nullable: false) Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Sqlite:Autoincrement", true),
Base64 = table.Column<string>(type: "TEXT", nullable: false) Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false),
ImageId = table.Column<int>(type: "INTEGER", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Images", x => x.Id); table.PrimaryKey("PK_Runes", x => x.Id);
table.ForeignKey(
name: "FK_Runes_Images_ImageId",
column: x => x.ImageId,
principalTable: "Images",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
@ -47,19 +76,32 @@ namespace EntityFramwork.Migrations
Description = table.Column<string>(type: "TEXT", nullable: false), Description = table.Column<string>(type: "TEXT", nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false), Icon = table.Column<string>(type: "TEXT", nullable: false),
Price = table.Column<float>(type: "REAL", nullable: false), Price = table.Column<float>(type: "REAL", nullable: false),
ChampionId = table.Column<int>(type: "INTEGER", nullable: false) ChampionForeignKey = table.Column<int>(type: "INTEGER", nullable: false),
ImageId = table.Column<int>(type: "INTEGER", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Skins", x => x.Id); table.PrimaryKey("PK_Skins", x => x.Id);
table.ForeignKey( table.ForeignKey(
name: "FK_Skins_Champions_ChampionId", name: "FK_Skins_Champions_ChampionForeignKey",
column: x => x.ChampionId, column: x => x.ChampionForeignKey,
principalTable: "Champions", principalTable: "Champions",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Skins_Images_ImageId",
column: x => x.ImageId,
principalTable: "Images",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateIndex(
name: "IX_Champions_ImageId",
table: "Champions",
column: "ImageId",
unique: true);
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Champions_Name", name: "IX_Champions_Name",
table: "Champions", table: "Champions",
@ -67,22 +109,37 @@ namespace EntityFramwork.Migrations
unique: true); unique: true);
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Skins_ChampionId", name: "IX_Runes_ImageId",
table: "Runes",
column: "ImageId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Skins_ChampionForeignKey",
table: "Skins",
column: "ChampionForeignKey");
migrationBuilder.CreateIndex(
name: "IX_Skins_ImageId",
table: "Skins", table: "Skins",
column: "ChampionId"); column: "ImageId",
unique: true);
} }
/// <inheritdoc /> /// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Images"); name: "Runes");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Skins"); name: "Skins");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Champions"); name: "Champions");
migrationBuilder.DropTable(
name: "Images");
} }
} }
} }

@ -30,12 +30,18 @@ namespace EntityFramwork.Migrations
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("ImageId")
.HasColumnType("INTEGER");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ImageId")
.IsUnique();
b.HasIndex("Name") b.HasIndex("Name")
.IsUnique(); .IsUnique();
@ -44,7 +50,7 @@ namespace EntityFramwork.Migrations
modelBuilder.Entity("EntityFramwork.EntityLargeImage", b => modelBuilder.Entity("EntityFramwork.EntityLargeImage", b =>
{ {
b.Property<long>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
@ -57,6 +63,35 @@ namespace EntityFramwork.Migrations
b.ToTable("Images"); b.ToTable("Images");
}); });
modelBuilder.Entity("EntityFramwork.EntityRunes", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("ImageId")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("ImageId")
.IsUnique();
b.ToTable("Runes");
});
modelBuilder.Entity("EntityFramwork.EntitySkins", b => modelBuilder.Entity("EntityFramwork.EntitySkins", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -74,6 +109,9 @@ namespace EntityFramwork.Migrations
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("ImageId")
.HasColumnType("INTEGER");
b.Property<float>("Price") b.Property<float>("Price")
.HasColumnType("REAL"); .HasColumnType("REAL");
@ -81,9 +119,34 @@ namespace EntityFramwork.Migrations
b.HasIndex("ChampionForeignKey"); b.HasIndex("ChampionForeignKey");
b.HasIndex("ImageId")
.IsUnique();
b.ToTable("Skins"); b.ToTable("Skins");
}); });
modelBuilder.Entity("DTO.EntityChampions", b =>
{
b.HasOne("EntityFramwork.EntityLargeImage", "Image")
.WithOne("Champion")
.HasForeignKey("DTO.EntityChampions", "ImageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Image");
});
modelBuilder.Entity("EntityFramwork.EntityRunes", b =>
{
b.HasOne("EntityFramwork.EntityLargeImage", "Image")
.WithOne("Rune")
.HasForeignKey("EntityFramwork.EntityRunes", "ImageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Image");
});
modelBuilder.Entity("EntityFramwork.EntitySkins", b => modelBuilder.Entity("EntityFramwork.EntitySkins", b =>
{ {
b.HasOne("DTO.EntityChampions", "Champion") b.HasOne("DTO.EntityChampions", "Champion")
@ -92,13 +155,33 @@ namespace EntityFramwork.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("EntityFramwork.EntityLargeImage", "Image")
.WithOne("Skin")
.HasForeignKey("EntityFramwork.EntitySkins", "ImageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Champion"); b.Navigation("Champion");
b.Navigation("Image");
}); });
modelBuilder.Entity("DTO.EntityChampions", b => modelBuilder.Entity("DTO.EntityChampions", b =>
{ {
b.Navigation("Skins"); b.Navigation("Skins");
}); });
modelBuilder.Entity("EntityFramwork.EntityLargeImage", b =>
{
b.Navigation("Champion")
.IsRequired();
b.Navigation("Rune")
.IsRequired();
b.Navigation("Skin")
.IsRequired();
});
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }

@ -39,7 +39,7 @@ namespace Model
public LargeImage Image { get; set; } public LargeImage Image { get; set; }
public Rune(string name, RuneFamily family, string icon = "", string image = "", string description = "") public Rune(string name, RuneFamily family, string icon = "Inconnu !", string image = "Inconnu !", string description = "Inconnu !")
{ {
Name = name; Name = name;
Family = family; Family = family;

@ -35,7 +35,7 @@ namespace Model
} }
private string description = ""; private string description = "";
public Skill(string name, SkillType type, string description = "") public Skill(string name, SkillType type, string description = "Inconnu !")
{ {
Name = name; Name = name;
Type = type; Type = type;

Loading…
Cancel
Save