Lucas Delanier 2 years ago
commit f15d5814cf

@ -0,0 +1,66 @@
kind: pipeline
type: docker
name: default
trigger:
event:
- push
steps:
- name: build
image: mcr.microsoft.com/dotnet/sdk:6.0
volumes:
- name: docs
path: /docs
commands:
- cd Sources/
- dotnet restore LeagueOfLegends.sln
- dotnet build LeagueOfLegends.sln -c Release --no-restore
- dotnet publish LeagueOfLegends.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release
- name: tests
image: mcr.microsoft.com/dotnet/sdk:6.0
commands:
- cd Sources/
- dotnet restore LeagueOfLegends.sln
- dotnet test LeagueOfLegends.sln --no-restore
depends_on: [build]
- name: code-analysis
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6
commands:
- cd Sources/
- dotnet restore LeagueOfLegends.sln
- dotnet sonarscanner begin /k:TEST /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="Tests/**" /d:sonar.login=$${PLUGIN_SONAR_TOKEN}
- dotnet build LeagueOfLegends.sln -c Release --no-restore
- dotnet test LeagueOfLegends.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage"
- reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport"
- dotnet publish LeagueOfLegends.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release
- dotnet sonarscanner end /d:sonar.login=$${PLUGIN_SONAR_TOKEN}
secrets: [ SECRET_SONAR_LOGIN ]
settings:
# accessible en ligne de commande par ${PLUGIN_SONAR_HOST}
sonar_host: https://codefirst.iut.uca.fr/sonar/
# accessible en ligne de commande par ${PLUGIN_SONAR_TOKEN}
sonar_token:
from_secret: SECRET_SONAR_LOGIN
depends_on: [tests]
- name: generate-and-deploy-docs
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer
failure: ignore
volumes:
- name: docs
path: /docs
commands:
#- cd Documentation/doxygen
#- doxygen Doxyfile
- /entrypoint.sh
when:
branch:
- master
depends_on: [ build ]
volumes:
- name: docs
temp: {}

@ -5,7 +5,6 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>036530f1-7b72-4f69-a1a3-0b4039b6a80a</UserSecretsId> <UserSecretsId>036530f1-7b72-4f69-a1a3-0b4039b6a80a</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -16,7 +15,6 @@
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup> </ItemGroup>

@ -1,13 +0,0 @@
using EntityFrameworkLOL.Entities;
using Microsoft.EntityFrameworkCore;
namespace EntityFrameworkLOL.DBContexts
{
class ChampionContext : DbContext
{
public DbSet<ChampionEntity> Champion { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source=DBLOL.db");
}
}

@ -1,13 +0,0 @@
using EntityFrameworkLOL.Entities;
using Microsoft.EntityFrameworkCore;
namespace EntityFrameworkLOL.DBContexts
{
class RuneContext : DbContext
{
public DbSet<RuneEntity> Rune { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source=DBLOL.db");
}
}

@ -5,11 +5,25 @@ namespace EntityFrameworkLOL.DBContexts
{ {
class SQLiteContext : DbContext class SQLiteContext : DbContext
{ {
/*public DbSet<ChampionEntity> Champion { get; set; } public DbSet<CategoryEntity> Category { get; set; }
public DbSet<SkinEntity> Skin { get; set; }*/ public DbSet<RuneFamilyEntity> RuneFamily { get; set; }
public DbSet<ImageEntity> Image { get; set; }
public DbSet<SkillTypeEntity> SkillType { get; set; }
//public DbSet<SkillEntity> Skill { get; set; }
public DbSet<SkinEntity> Skin { get; set; }
public DbSet<RuneEntity> Rune { get; set; } public DbSet<RuneEntity> Rune { get; set; }
public DbSet<ChampionClassEntity> ChampionClass { get; set; }
public DbSet<RunePageEntity> RunePage { get; set; }
public DbSet<ChampionEntity> Champion { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options) protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source=DBLOL.db"); => options.UseSqlite($"Data Source=DBLOL.db");
public SQLiteContext()
{ }
public SQLiteContext(DbContextOptions<SQLiteContext> options)
: base(options)
{ }
} }
} }

@ -1,13 +0,0 @@
using EntityFrameworkLOL.Entities;
using Microsoft.EntityFrameworkCore;
namespace EntityFrameworkLOL.DBContexts
{
class SkinContext : DbContext
{
public DbSet<SkinEntity> Skin { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source=DBLOL.db");
}
}

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Xml.Linq;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using Model;
using static System.Net.Mime.MediaTypeNames;
using System.Reflection.PortableExecutable;
using System.Security.Claims;
namespace EntityFrameworkLOL.Entities
{
class CategoryEntity
{
[Key]
[ForeignKey("RunePageEntity")]
public RunePage.Category Category { get; set; }
}
}

@ -0,0 +1,21 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.DataAnnotations;
using Model;
using System.ComponentModel.DataAnnotations.Schema;
namespace EntityFrameworkLOL.Entities
{
class ChampionClassEntity
{
[Key]
[ForeignKey("ChampionEntity")]
public int Id { get; set; }
public ChampionClass Class { get; set; }
}
}

@ -6,6 +6,12 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Xml.Linq; using System.Xml.Linq;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using Model;
using static System.Net.Mime.MediaTypeNames;
using System.Reflection.PortableExecutable;
using System.Security.Claims;
namespace EntityFrameworkLOL.Entities namespace EntityFrameworkLOL.Entities
{ {
@ -17,5 +23,15 @@ namespace EntityFrameworkLOL.Entities
public string Bio { get; set; } public string Bio { get; set; }
public string Icon { get; set; } public string Icon { get; set; }
[NotMapped]
public Dictionary<string, int> Characteristics { get; set; }
// Switch Dictionary to List puis faudra juste mapper la liste en dico
public ChampionClassEntity Class { get; set; }
public ImageEntity Image { get; set; }
//public ICollection<Skill> Skills { get; set; }
} }
} }

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Xml.Linq;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using Model;
using static System.Net.Mime.MediaTypeNames;
using System.Reflection.PortableExecutable;
using System.Security.Claims;
namespace EntityFrameworkLOL.Entities
{
class ImageEntity
{
[Key]
[ForeignKey("ChampionEntity")]
public string Base64 { get; set; }
}
}

@ -14,5 +14,9 @@ namespace EntityFrameworkLOL.Entities
public string Name { get; set; } public string Name { get; set; }
public string Description { get; set; } public string Description { get; set; }
public ImageEntity Image { get; set; }
public RuneFamilyEntity Family { get; set; }
} }
} }

@ -0,0 +1,21 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.DataAnnotations;
using Model;
using System.ComponentModel.DataAnnotations.Schema;
namespace EntityFrameworkLOL.Entities
{
class RuneFamilyEntity
{
[Key]
[ForeignKey("RuneEntity")]
public int Id { get; set; }
public RuneFamily Family { get; set; }
}
}

@ -0,0 +1,27 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Xml.Linq;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using Model;
using static System.Net.Mime.MediaTypeNames;
using System.Reflection.PortableExecutable;
using System.Security.Claims;
namespace EntityFrameworkLOL.Entities
{
class RunePageEntity
{
[Key]
public string Name { get; set; }
[NotMapped]
public Dictionary<CategoryEntity, RuneEntity> Dictionary { get; set; }
// Switch Dictionary to List puis faudra juste mapper la liste en dico
}
}

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace EntityFrameworkLOL.Entities
{
class SkillEntity
{
[Key]
public string Name { get; set; }
public string Description { get; set; }
public SkillTypeEntity Type { get; set; }
[NotMapped]
public ICollection<ChampionEntity> Champions { get; set; }
}
}

@ -0,0 +1,19 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.DataAnnotations;
using Model;
using System.ComponentModel.DataAnnotations.Schema;
namespace EntityFrameworkLOL.Entities
{
class SkillTypeEntity
{
[Key]
[ForeignKey("SkillEntity")]
public SkillType Type { get; set; }
}
}

@ -15,8 +15,12 @@ namespace EntityFrameworkLOL.Entities
public string Description { get; set; } public string Description { get; set; }
/*public string Icon { get; set; } public string Icon { get; set; }
public float Price { get; set; }*/ public float Price { get; set; }
public ImageEntity Image { get; set; }
public ChampionEntity ChampionSkin { get; set; }
} }
} }

@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<StartWorkingDirectory>$(MSBuildProjectDirectory)</StartWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -24,4 +25,8 @@
<Folder Include="Migrations\" /> <Folder Include="Migrations\" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project> </Project>

@ -1,38 +0,0 @@
// <auto-generated />
using EntityFrameworkLOL.DBContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameworkLOL.Migrations
{
[DbContext(typeof(SQLiteContext))]
[Migration("20230202105714_MigrationWallah2")]
partial class MigrationWallah2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("Rune");
});
#pragma warning restore 612, 618
}
}
}

@ -1,33 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameworkLOL.Migrations
{
/// <inheritdoc />
public partial class MigrationWallah2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Rune",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Rune", x => x.Name);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Rune");
}
}
}

@ -0,0 +1,227 @@
// <auto-generated />
using EntityFrameworkLOL.DBContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameworkLOL.Migrations
{
[DbContext(typeof(SQLiteContext))]
[Migration("20230208161248_MigrationWallah4")]
partial class MigrationWallah4
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFrameworkLOL.Entities.CategoryEntity", b =>
{
b.Property<int>("Category")
.HasColumnType("INTEGER");
b.HasKey("Category");
b.ToTable("Category");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionClassEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("ChampionClass");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("ClassId")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ImageBase64")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.HasIndex("ClassId");
b.HasIndex("ImageBase64");
b.ToTable("Champion");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ImageEntity", b =>
{
b.Property<string>("Base64")
.HasColumnType("TEXT");
b.HasKey("Base64");
b.ToTable("Image");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("FamilyId")
.HasColumnType("INTEGER");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.HasKey("Name");
b.HasIndex("FamilyId");
b.HasIndex("ImageBase64");
b.ToTable("Rune");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneFamilyEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("Family")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("RuneFamily");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RunePageEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("RunePage");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkillTypeEntity", b =>
{
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("Type");
b.ToTable("SkillType");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("ChampionSkinName")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.Property<float>("Price")
.HasColumnType("REAL");
b.HasKey("Name");
b.HasIndex("ChampionSkinName");
b.HasIndex("ImageBase64");
b.ToTable("Skin");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionClassEntity", "Class")
.WithMany()
.HasForeignKey("ClassId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Class");
b.Navigation("Image");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.RuneFamilyEntity", "Family")
.WithMany()
.HasForeignKey("FamilyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("Family");
b.Navigation("Image");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "ChampionSkin")
.WithMany()
.HasForeignKey("ChampionSkinName");
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("ChampionSkin");
b.Navigation("Image");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,223 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameworkLOL.Migrations
{
/// <inheritdoc />
public partial class MigrationWallah4 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Category",
columns: table => new
{
Category = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Category", x => x.Category);
});
migrationBuilder.CreateTable(
name: "ChampionClass",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Class = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ChampionClass", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Image",
columns: table => new
{
Base64 = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Image", x => x.Base64);
});
migrationBuilder.CreateTable(
name: "RuneFamily",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Family = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RuneFamily", x => x.Id);
});
migrationBuilder.CreateTable(
name: "RunePage",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RunePage", x => x.Name);
});
migrationBuilder.CreateTable(
name: "SkillType",
columns: table => new
{
Type = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SkillType", x => x.Type);
});
migrationBuilder.CreateTable(
name: "Champion",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Bio = table.Column<string>(type: "TEXT", nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false),
ClassId = table.Column<int>(type: "INTEGER", nullable: false),
ImageBase64 = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Champion", x => x.Name);
table.ForeignKey(
name: "FK_Champion_ChampionClass_ClassId",
column: x => x.ClassId,
principalTable: "ChampionClass",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Champion_Image_ImageBase64",
column: x => x.ImageBase64,
principalTable: "Image",
principalColumn: "Base64",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Rune",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
ImageBase64 = table.Column<string>(type: "TEXT", nullable: true),
FamilyId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Rune", x => x.Name);
table.ForeignKey(
name: "FK_Rune_Image_ImageBase64",
column: x => x.ImageBase64,
principalTable: "Image",
principalColumn: "Base64");
table.ForeignKey(
name: "FK_Rune_RuneFamily_FamilyId",
column: x => x.FamilyId,
principalTable: "RuneFamily",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Skin",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false),
Price = table.Column<float>(type: "REAL", nullable: false),
ImageBase64 = table.Column<string>(type: "TEXT", nullable: true),
ChampionSkinName = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Skin", x => x.Name);
table.ForeignKey(
name: "FK_Skin_Champion_ChampionSkinName",
column: x => x.ChampionSkinName,
principalTable: "Champion",
principalColumn: "Name");
table.ForeignKey(
name: "FK_Skin_Image_ImageBase64",
column: x => x.ImageBase64,
principalTable: "Image",
principalColumn: "Base64");
});
migrationBuilder.CreateIndex(
name: "IX_Champion_ClassId",
table: "Champion",
column: "ClassId");
migrationBuilder.CreateIndex(
name: "IX_Champion_ImageBase64",
table: "Champion",
column: "ImageBase64");
migrationBuilder.CreateIndex(
name: "IX_Rune_FamilyId",
table: "Rune",
column: "FamilyId");
migrationBuilder.CreateIndex(
name: "IX_Rune_ImageBase64",
table: "Rune",
column: "ImageBase64");
migrationBuilder.CreateIndex(
name: "IX_Skin_ChampionSkinName",
table: "Skin",
column: "ChampionSkinName");
migrationBuilder.CreateIndex(
name: "IX_Skin_ImageBase64",
table: "Skin",
column: "ImageBase64");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Category");
migrationBuilder.DropTable(
name: "Rune");
migrationBuilder.DropTable(
name: "RunePage");
migrationBuilder.DropTable(
name: "SkillType");
migrationBuilder.DropTable(
name: "Skin");
migrationBuilder.DropTable(
name: "RuneFamily");
migrationBuilder.DropTable(
name: "Champion");
migrationBuilder.DropTable(
name: "ChampionClass");
migrationBuilder.DropTable(
name: "Image");
}
}
}

@ -16,6 +16,69 @@ namespace EntityFrameworkLOL.Migrations
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFrameworkLOL.Entities.CategoryEntity", b =>
{
b.Property<int>("Category")
.HasColumnType("INTEGER");
b.HasKey("Category");
b.ToTable("Category");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionClassEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("ChampionClass");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("ClassId")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ImageBase64")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.HasIndex("ClassId");
b.HasIndex("ImageBase64");
b.ToTable("Champion");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ImageEntity", b =>
{
b.Property<string>("Base64")
.HasColumnType("TEXT");
b.HasKey("Base64");
b.ToTable("Image");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b => modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{ {
b.Property<string>("Name") b.Property<string>("Name")
@ -25,10 +88,136 @@ namespace EntityFrameworkLOL.Migrations
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("FamilyId")
.HasColumnType("INTEGER");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.HasKey("Name"); b.HasKey("Name");
b.HasIndex("FamilyId");
b.HasIndex("ImageBase64");
b.ToTable("Rune"); b.ToTable("Rune");
}); });
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneFamilyEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("Family")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("RuneFamily");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RunePageEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("RunePage");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkillTypeEntity", b =>
{
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("Type");
b.ToTable("SkillType");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("ChampionSkinName")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.Property<float>("Price")
.HasColumnType("REAL");
b.HasKey("Name");
b.HasIndex("ChampionSkinName");
b.HasIndex("ImageBase64");
b.ToTable("Skin");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionClassEntity", "Class")
.WithMany()
.HasForeignKey("ClassId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Class");
b.Navigation("Image");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.RuneFamilyEntity", "Family")
.WithMany()
.HasForeignKey("FamilyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("Family");
b.Navigation("Image");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "ChampionSkin")
.WithMany()
.HasForeignKey("ChampionSkinName");
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("ChampionSkin");
b.Navigation("Image");
});
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }

@ -8,14 +8,14 @@ class Program
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
/*ChampionEntity akali = new ChampionEntity {Name="Akali"}; ChampionEntity akali = new ChampionEntity { Name = "Akali", Bio = "" };
ChampionEntity aatrox = new ChampionEntity { Name = "Aatrox" }; ChampionEntity aatrox = new ChampionEntity { Name = "Aatrox", Bio = "" };
ChampionEntity ahri = new ChampionEntity { Name = "Ahri" }; ChampionEntity ahri = new ChampionEntity { Name = "Ahri", Bio = "" };
ChampionEntity bard = new ChampionEntity { Name = "Bard" }; ChampionEntity bard = new ChampionEntity { Name = "Bard", Bio = "" };
ChampionEntity alistar = new ChampionEntity { Name = "Alistar" }; ChampionEntity alistar = new ChampionEntity { Name = "Alistar", Bio = "" };
ChampionEntity akshan = new ChampionEntity { Name = "Akshan" }; ChampionEntity akshan = new ChampionEntity { Name = "Akshan", Bio = "" };
using (var context = new ChampionContext()) using (var context = new SQLiteContext())
{ {
// Crée des champions et les insère dans la base // Crée des champions et les insère dans la base
Console.WriteLine("Creates and inserts new Champions"); Console.WriteLine("Creates and inserts new Champions");
@ -27,11 +27,11 @@ class Program
context.Add(akshan); context.Add(akshan);
context.SaveChanges(); context.SaveChanges();
Console.WriteLine("Creates and executes a query retrieving the first Champion of the database whose name starts with an \"A\":"); Console.WriteLine("Creates and executes a query retrieving the first Champion of the database whose name starts with an \"A\":");
var aChampion = context.Champions var aChampion = context.Champion
.Where(c => c.Name.StartsWith("A")) .Where(c => c.Name.StartsWith("A"))
.First(); .First();
Console.WriteLine($"{aChampion.Name} (with bio : {aChampion.Bio}"); Console.WriteLine($"{aChampion.Name} (with bio : \"{aChampion.Bio}\")");
}*/ }
RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "" }; RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "" };
RuneEntity thriumph = new RuneEntity { Name = "Thriumph", Description = "" }; RuneEntity thriumph = new RuneEntity { Name = "Thriumph", Description = "" };
@ -40,7 +40,7 @@ class Program
RuneEntity laststand = new RuneEntity { Name = "Last Stand", Description = "" }; RuneEntity laststand = new RuneEntity { Name = "Last Stand", Description = "" };
RuneEntity laststand2 = new RuneEntity { Name = "Last Stand 2", Description = "" }; RuneEntity laststand2 = new RuneEntity { Name = "Last Stand 2", Description = "" };
using (var context = new RuneContext()) using (var context = new SQLiteContext())
{ {
// Crée des Runes et les insère dans la base // Crée des Runes et les insère dans la base
Console.WriteLine("Creates and inserts new Runes"); Console.WriteLine("Creates and inserts new Runes");
@ -55,17 +55,17 @@ class Program
var lRune = context.Rune var lRune = context.Rune
.Where(r => r.Name.StartsWith("L")) .Where(r => r.Name.StartsWith("L"))
.First(); .First();
Console.WriteLine($"{lRune.Name} (with Description : {lRune.Description}"); Console.WriteLine($"{lRune.Name} (with Description : \"{lRune.Description}\")");
} }
/*SkinEntity stinger = new SkinEntity { Name = "Stinger", Description = "" }; SkinEntity stinger = new SkinEntity { Name = "Stinger", Description = "" };
SkinEntity infernal = new SkinEntity { Name = "Infernal", Description = "" }; SkinEntity infernal = new SkinEntity { Name = "Infernal", Description = "" };
SkinEntity allStar = new SkinEntity { Name = "All-Star", Description = "" }; SkinEntity allStar = new SkinEntity { Name = "All-Star", Description = "" };
SkinEntity justicar = new SkinEntity { Name = "Justicar", Description = "" }; SkinEntity justicar = new SkinEntity { Name = "Justicar", Description = "" };
SkinEntity mecha = new SkinEntity { Name = "Mecha", Description = "" }; SkinEntity mecha = new SkinEntity { Name = "Mecha", Description = "" };
SkinEntity seaHunter = new SkinEntity { Name = "Sea Hunter", Description = "" }; SkinEntity seaHunter = new SkinEntity { Name = "Sea Hunter", Description = "" };
using (var context = new SkinContext()) using (var context = new SQLiteContext())
{ {
// Crée des Skins et les insère dans la base // Crée des Skins et les insère dans la base
Console.WriteLine("Creates and inserts new Skins"); Console.WriteLine("Creates and inserts new Skins");
@ -80,18 +80,28 @@ class Program
var iSkin = context.Skin var iSkin = context.Skin
.Where(s => s.Name.StartsWith("I")) .Where(s => s.Name.StartsWith("I"))
.First(); .First();
Console.WriteLine($"{iSkin.Name} (with Description : {iSkin.Description}"); Console.WriteLine($"{iSkin.Name} (with Description : \"{iSkin.Description}\")");
Console.WriteLine("Updates the name of the Infernal Skin"); Console.WriteLine("Updates the name of the Infernal Skin");
iSkin.Name = "Infernal of Hell (Wallah)"; iSkin.Description = "Hella Infernal (Wallah)";
context.SaveChanges(); context.SaveChanges();
Console.WriteLine($"{iSkin.Name} (with Description : {iSkin.Description}"); Console.WriteLine($"{iSkin.Name} (with Description : \"{iSkin.Description}\")");
Console.WriteLine("Deletes one item from the database"); Console.WriteLine("Deletes one item from the database");
var droid = context.Skin var droid = context.Skin
.SingleOrDefault(s => s.Name.Equals("Infernal")); .SingleOrDefault(s => s.Name.Equals("Infernal"));
context.Remove(droid); context.Remove(droid);
context.SaveChanges(); context.SaveChanges();
}*/ }
using (var context = new SQLiteContext())
{
foreach (var c in context.Champion)
{
c.Bio = $"{c.Name}";
Console.WriteLine($"{c.Name} - {c.Bio}");
}
context.SaveChanges();
}
} }
} }

@ -17,6 +17,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\APILOL\APILOL.csproj" /> <ProjectReference Include="..\APILOL\APILOL.csproj" />
<ProjectReference Include="..\DTO\DTO.csproj" />
<ProjectReference Include="..\StubLib\StubLib.csproj" /> <ProjectReference Include="..\StubLib\StubLib.csproj" />
</ItemGroup> </ItemGroup>

Loading…
Cancel
Save