Compare commits

..

1 Commits

Author SHA1 Message Date
Maxence LANONE 1c5fb72f00 add SkillEntity + LargeImageEntity + RuneEntity + relation oneToOne entre image et champion
continuous-integration/drone/push Build is failing Details
2 years ago

@ -11,29 +11,31 @@ steps:
- name: build
image: mcr.microsoft.com/dotnet/sdk:7.0
commands:
- cd Sources/
- dotnet restore LeagueOfLegends_CI.sln
- dotnet build LeagueOfLegends_CI.sln -c Release --no-restore
- dotnet publish LeagueOfLegends_CI.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release
- cd Sources/LolApp/
- dotnet workload restore
- cd ..
- 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:7.0
commands:
- cd Sources/
- dotnet restore LeagueOfLegends_CI.sln
- dotnet test LeagueOfLegends_CI.sln --no-restore
- dotnet restore LeagueOfLegends.sln
- dotnet test LeagueOfLegends.sln --no-restore
depends_on: [build]
- name: code-analysis
image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet7
commands:
- cd Sources/
- dotnet restore LeagueOfLegends_CI.sln
- dotnet restore LeagueOfLegends.sln
- dotnet sonarscanner begin /k:EfCore_Lol_S4 /d:sonar.host.url="https://codefirst.iut.uca.fr/sonar" /d:sonar.coverage.exclusions="Tests/**" /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.login=$${PLUGIN_SONAR_TOKEN}
- dotnet build LeagueOfLegends_CI.sln -c Release --no-restore
- dotnet test LeagueOfLegends_CI.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage"
- 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_CI.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release
- 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:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

@ -18,42 +18,6 @@ Ce dépot réuni plusieurs choses :
- Une documentation de l'api avec les différentes requetes possible.
- Plusieurs schémas dont l'architechture de l'ORM et le lien entre les différents éléments (ORM, API, Application mobile).
## Avancement des projets
# :zap: Consommation et Développement de services
> * :white_check_mark: La mise en place de toutes les opérations CRUD est terminée.
> * :white_check_mark: Une API RESTful a été mise en place en respectant les règles de routage et en utilisant les bons codes de statut.
> * :construction: La version de l'API a été gérée de manière appropriée.
> * :white_check_mark: Les logs ont été implémentés.
> * :construction: Les tests unitaires sont en cours de réalisation.
> * :construction: La création du client MAUI et sa liaison avec l'API sont en cours de réalisation.
> * :construction: La liaison avec la base de données est opérationnelle.
> * :construction: Le filtrage et la pagination des données ont été implémentés.
> * :white_check_mark: Le code est de qualité grâce à l'utilisation de SonarQube.
> * :white_check_mark: L'API a été dockerisée et hébergée sur CodeFirst.
> * :construction: Sécurité
`Note : Le client MAUI a été mis en place mais il n'utilise que le stub actuellement et n'est pas relié à l'api.`
---
# :zap: Entity Framework :
Voici l'état des différentes tâches liées à Entity Framework :
> * :white_check_mark: **Exercice 1** : Une base de données a été créée avec une table pour les champions, et des requêtes CRUD ont été implémentées, ainsi que du filtrage et de la pagination. Le client console n'a pas été réalisé pour cet exercice par manque de temps.
> * :white_check_mark: **Exercice 2** : Des tests unitaires ont été écrits et une base de données a été simulée à l'aide de SQLiteInMemory.
> * :white_check_mark: **Exercice 3** : Entity Framework a été déployé et les tests ont été effectués via Code#0.
> * :white_check_mark: **Exercice 4**: Les tables pour les runes et les skins ont été implémentées (sans les relations).
> * :white_check_mark: **Exercice 5** : Une relation OneToMany a été établie entre les champions et les skins.
> * :white_check_mark: **Exercice 6** : Une relation ManyToMany a été établie entre les champions, les rune pages et les runes.
> * :construction: **Exercice 7** : Le mapping entre le modèle et l'entité a été réalisé pour améliorer la qualité du code.
> * :construction: **Exercice 8** : La mise en place du pattern UnitOfWork n'a pas pu être implémentée par manque de temps.
---
# Lancer le projet
@ -64,28 +28,9 @@ Cette partie est réalisé avec un mac, toutes les manipulations qui vont suivre
:construction:
## IOS
### 1 - Cloner le dépot
Ouvrer Visual Studio Pour Mac, cloner le depot a l'aide du lien suivant:
https://codefirst.iut.uca.fr/git/maxence.lanone/EfCore_LoL_S4.git
### 3 - Configurer le démarrage du projet
> clique droit sur le projet dans l'explorateur de solution > Set Startup Projects
Et selectionner soit LolApp + WebApiLol, soit ConsoleTests + WebApiLol.
### 4 - Lancement du projet
Vous pouvez alors lancer le projet grâce à la flèche verte, bonne navigation !
:construction:
# Documention
Rendez vous sur la partie wiki du projet pour accéder aux différents diagrammes ainsi qu'à la documention de l'api.
# Réalisation
Projet réalisé par Maxence Lanone, élève en PM3.
Rendez vous sur la partie wiki du projet pour accéder aux différents diagrammes ainsi qu'à la documention de l'api.

@ -1,7 +1,6 @@
using System;
using EntityFrameWorkLib;
using Model;
using Shared;
namespace DbDatamanager
{

@ -1,8 +1,6 @@
using System;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Shared;
namespace EntityFrameWorkLib
{
@ -12,24 +10,18 @@ namespace EntityFrameWorkLib
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int UniqueId { get; set; }
public string? Name { get; set; }
public string Name { get; set; }
//[Required]
[Required]
[MaxLength(256)]
public string? Bio { get; set; }
public string Bio { get; set; }
public string? Icon { get; set; }
public string Icon { get; set; }
//[Required]
[Required]
public ChampionClass Class { get; set; }
public Collection<SkinEntity>? Skins { get; set; }
public LargeImageEntity? LargeImage { get; set; }
public HashSet<SkillEntity> skills = new HashSet<SkillEntity>();
public Collection<RunePageEntity>? ListRunePages { get; set; }
}
public LargeImageEntity? LargeImageEntity { get; set; }
}
}

@ -12,6 +12,7 @@
<None Remove="Microsoft.EntityFrameworkCore.Sqlite" />
<None Remove="Microsoft.EntityFrameworkCore.Tools" />
<None Remove="Microsoft.EntityFrameworkCore.Design" />
<None Remove="enums\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
@ -26,6 +27,6 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\Shared.csproj" />
<Folder Include="enums\" />
</ItemGroup>
</Project>

@ -8,14 +8,14 @@ namespace EntityFrameWorkLib
[Key]
public Guid Id { get; set; }
//[Required]
public string? Base64 { get; set; }
[Required]
public string Base64 { get; set; }
//[Required]
[Required]
public int championId { get; set; }
//[Required]
public ChampionEntity? champion { get; set; }
[Required]
public ChampionEntity champion { get; set; }
}
}

@ -6,52 +6,39 @@ namespace EntityFrameWorkLib
{
public class LolContext : DbContext
{
public DbSet<ChampionEntity> Champions { get; set; }
public DbSet<SkillEntity> Skill { get; set; }
public DbSet<LargeImageEntity> LargeImage { get; set; }
public DbSet<RuneEntity> Runes { get; set; }
public DbSet<RunePageEntity> RunesPage { get; set; }
public DbSet<SkinEntity> Skins { get; set; }
public LolContext() { }
public LolContext(DbContextOptions<LolContext> options)
: base(options)
{ }
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
if (!options.IsConfigured)
{
public DbSet<ChampionEntity> Champions { get; set; }
public DbSet<SkillEntity> Skill { get; set; }
public DbSet<LargeImageEntity> LargeImage { get; set; }
public LolContext() { }
public LolContext(DbContextOptions<LolContext> options)
:base(options)
{ }
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
if (!options.IsConfigured)
{
base.OnConfiguring(options.UseSqlite($"DataSource=projet.Champions.db"));
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
//Définition de la clé primaire de ChampionEntity
modelBuilder.Entity<ChampionEntity>().HasKey(n => n.UniqueId);
//Définition du mode de generation de la clé : génération à l'insertion
modelBuilder.Entity<ChampionEntity>().Property(n => n.UniqueId).ValueGeneratedOnAdd();
modelBuilder.Entity<ChampionEntity>()
.HasOne(c => c.LargeImage)
.WithOne(li => li.champion)
.HasForeignKey<LargeImageEntity>(li => li.championId);
modelBuilder.Entity<SkinEntity>()
.Property(s => s.Name)
.ValueGeneratedOnAdd();
modelBuilder.Entity<RunePageEntity>()
.Property(s => s.Id)
.ValueGeneratedOnAdd();
modelBuilder.Entity<RuneEntity>()
.Property(s => s.Name)
.ValueGeneratedOnAdd();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
//Définition de la clé primaire de ChampionEntity
modelBuilder.Entity<ChampionEntity>().HasKey(n => n.UniqueId);
//Définition du mode de generation de la clé : génération à l'insertion
modelBuilder.Entity<ChampionEntity>().Property(n => n.UniqueId).ValueGeneratedOnAdd();
modelBuilder.Entity<ChampionEntity>()
.HasOne(c => c.LargeImageEntity)
.WithOne(li => li.champion)
.HasForeignKey<LargeImageEntity>(li => li.championId);
}
base.OnModelCreating(modelBuilder);
}
}
}

@ -0,0 +1,108 @@
// <auto-generated />
using System;
using EntityFrameWorkLib;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameWorkLib.Migrations
{
[DbContext(typeof(LolContext))]
[Migration("20230314230906_MyMigration")]
partial class MyMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.4");
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.Property<int>("UniqueId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("UniqueId");
b.ToTable("Champions");
});
modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("Base64")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("championId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("championId")
.IsUnique();
b.ToTable("LargeImage");
});
modelBuilder.Entity("EntityFrameWorkLib.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("Skill");
});
modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", "champion")
.WithOne("LargeImageEntity")
.HasForeignKey("EntityFrameWorkLib.LargeImageEntity", "championId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("champion");
});
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.Navigation("LargeImageEntity");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,82 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameWorkLib.Migrations
{
/// <inheritdoc />
public partial class MyMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Champions",
columns: table => new
{
UniqueId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
Bio = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false),
Class = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Champions", x => x.UniqueId);
});
migrationBuilder.CreateTable(
name: "Skill",
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_Skill", x => x.Name);
});
migrationBuilder.CreateTable(
name: "LargeImage",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Base64 = table.Column<string>(type: "TEXT", nullable: false),
championId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LargeImage", x => x.Id);
table.ForeignKey(
name: "FK_LargeImage_Champions_championId",
column: x => x.championId,
principalTable: "Champions",
principalColumn: "UniqueId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_LargeImage_championId",
table: "LargeImage",
column: "championId",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "LargeImage");
migrationBuilder.DropTable(
name: "Skill");
migrationBuilder.DropTable(
name: "Champions");
}
}
}

@ -1,225 +0,0 @@
// <auto-generated />
using System;
using EntityFrameWorkLib;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameWorkLib.Migrations
{
[DbContext(typeof(LolContext))]
[Migration("20230326210027_MyMigration")]
partial class MyMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.4");
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.Property<int>("UniqueId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("SkillEntityName")
.HasColumnType("TEXT");
b.HasKey("UniqueId");
b.HasIndex("SkillEntityName");
b.ToTable("Champions");
});
modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("Base64")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("championId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("championId")
.IsUnique();
b.ToTable("LargeImage");
});
modelBuilder.Entity("EntityFrameWorkLib.RuneEntity", b =>
{
b.Property<string>("Name")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<int>("RuneFamily")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.ToTable("Runes");
});
modelBuilder.Entity("EntityFrameWorkLib.RunePageEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("ChampionEntityUniqueId")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("RuneEntityName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("ChampionEntityUniqueId");
b.HasIndex("RuneEntityName");
b.ToTable("RunesPage");
});
modelBuilder.Entity("EntityFrameWorkLib.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("Skill");
});
modelBuilder.Entity("EntityFrameWorkLib.SkinEntity", b =>
{
b.Property<string>("Name")
.ValueGeneratedOnAdd()
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<int?>("ChampionEntityUniqueId")
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Price")
.HasColumnType("REAL");
b.HasKey("Name");
b.HasIndex("ChampionEntityUniqueId");
b.ToTable("Skins");
});
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.HasOne("EntityFrameWorkLib.SkillEntity", null)
.WithMany("champions")
.HasForeignKey("SkillEntityName");
});
modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", "champion")
.WithOne("LargeImage")
.HasForeignKey("EntityFrameWorkLib.LargeImageEntity", "championId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("champion");
});
modelBuilder.Entity("EntityFrameWorkLib.RunePageEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", null)
.WithMany("ListRunePages")
.HasForeignKey("ChampionEntityUniqueId");
b.HasOne("EntityFrameWorkLib.RuneEntity", null)
.WithMany("ListRunePages")
.HasForeignKey("RuneEntityName");
});
modelBuilder.Entity("EntityFrameWorkLib.SkinEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", null)
.WithMany("Skins")
.HasForeignKey("ChampionEntityUniqueId");
});
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.Navigation("LargeImage");
b.Navigation("ListRunePages");
b.Navigation("Skins");
});
modelBuilder.Entity("EntityFrameWorkLib.RuneEntity", b =>
{
b.Navigation("ListRunePages");
});
modelBuilder.Entity("EntityFrameWorkLib.SkillEntity", b =>
{
b.Navigation("champions");
});
#pragma warning restore 612, 618
}
}
}

@ -1,175 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameWorkLib.Migrations
{
/// <inheritdoc />
public partial class MyMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Runes",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
RuneFamily = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Runes", x => x.Name);
});
migrationBuilder.CreateTable(
name: "Skill",
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_Skill", x => x.Name);
});
migrationBuilder.CreateTable(
name: "Champions",
columns: table => new
{
UniqueId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
Bio = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false),
Class = table.Column<int>(type: "INTEGER", nullable: false),
SkillEntityName = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Champions", x => x.UniqueId);
table.ForeignKey(
name: "FK_Champions_Skill_SkillEntityName",
column: x => x.SkillEntityName,
principalTable: "Skill",
principalColumn: "Name");
});
migrationBuilder.CreateTable(
name: "LargeImage",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Base64 = table.Column<string>(type: "TEXT", nullable: false),
championId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LargeImage", x => x.Id);
table.ForeignKey(
name: "FK_LargeImage_Champions_championId",
column: x => x.championId,
principalTable: "Champions",
principalColumn: "UniqueId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "RunesPage",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
ChampionEntityUniqueId = table.Column<int>(type: "INTEGER", nullable: true),
RuneEntityName = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RunesPage", x => x.Id);
table.ForeignKey(
name: "FK_RunesPage_Champions_ChampionEntityUniqueId",
column: x => x.ChampionEntityUniqueId,
principalTable: "Champions",
principalColumn: "UniqueId");
table.ForeignKey(
name: "FK_RunesPage_Runes_RuneEntityName",
column: x => x.RuneEntityName,
principalTable: "Runes",
principalColumn: "Name");
});
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),
ChampionEntityUniqueId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Skins", x => x.Name);
table.ForeignKey(
name: "FK_Skins_Champions_ChampionEntityUniqueId",
column: x => x.ChampionEntityUniqueId,
principalTable: "Champions",
principalColumn: "UniqueId");
});
migrationBuilder.CreateIndex(
name: "IX_Champions_SkillEntityName",
table: "Champions",
column: "SkillEntityName");
migrationBuilder.CreateIndex(
name: "IX_LargeImage_championId",
table: "LargeImage",
column: "championId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_RunesPage_ChampionEntityUniqueId",
table: "RunesPage",
column: "ChampionEntityUniqueId");
migrationBuilder.CreateIndex(
name: "IX_RunesPage_RuneEntityName",
table: "RunesPage",
column: "RuneEntityName");
migrationBuilder.CreateIndex(
name: "IX_Skins_ChampionEntityUniqueId",
table: "Skins",
column: "ChampionEntityUniqueId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "LargeImage");
migrationBuilder.DropTable(
name: "RunesPage");
migrationBuilder.DropTable(
name: "Skins");
migrationBuilder.DropTable(
name: "Runes");
migrationBuilder.DropTable(
name: "Champions");
migrationBuilder.DropTable(
name: "Skill");
}
}
}

@ -39,13 +39,8 @@ namespace EntityFrameWorkLib.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("SkillEntityName")
.HasColumnType("TEXT");
b.HasKey("UniqueId");
b.HasIndex("SkillEntityName");
b.ToTable("Champions");
});
@ -70,50 +65,6 @@ namespace EntityFrameWorkLib.Migrations
b.ToTable("LargeImage");
});
modelBuilder.Entity("EntityFrameWorkLib.RuneEntity", b =>
{
b.Property<string>("Name")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<int>("RuneFamily")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.ToTable("Runes");
});
modelBuilder.Entity("EntityFrameWorkLib.RunePageEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("ChampionEntityUniqueId")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("RuneEntityName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("ChampionEntityUniqueId");
b.HasIndex("RuneEntityName");
b.ToTable("RunesPage");
});
modelBuilder.Entity("EntityFrameWorkLib.SkillEntity", b =>
{
b.Property<string>("Name")
@ -133,46 +84,10 @@ namespace EntityFrameWorkLib.Migrations
b.ToTable("Skill");
});
modelBuilder.Entity("EntityFrameWorkLib.SkinEntity", b =>
{
b.Property<string>("Name")
.ValueGeneratedOnAdd()
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<int?>("ChampionEntityUniqueId")
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Price")
.HasColumnType("REAL");
b.HasKey("Name");
b.HasIndex("ChampionEntityUniqueId");
b.ToTable("Skins");
});
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.HasOne("EntityFrameWorkLib.SkillEntity", null)
.WithMany("champions")
.HasForeignKey("SkillEntityName");
});
modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", "champion")
.WithOne("LargeImage")
.WithOne("LargeImageEntity")
.HasForeignKey("EntityFrameWorkLib.LargeImageEntity", "championId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -180,41 +95,9 @@ namespace EntityFrameWorkLib.Migrations
b.Navigation("champion");
});
modelBuilder.Entity("EntityFrameWorkLib.RunePageEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", null)
.WithMany("ListRunePages")
.HasForeignKey("ChampionEntityUniqueId");
b.HasOne("EntityFrameWorkLib.RuneEntity", null)
.WithMany("ListRunePages")
.HasForeignKey("RuneEntityName");
});
modelBuilder.Entity("EntityFrameWorkLib.SkinEntity", b =>
{
b.HasOne("EntityFrameWorkLib.ChampionEntity", null)
.WithMany("Skins")
.HasForeignKey("ChampionEntityUniqueId");
});
modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
{
b.Navigation("LargeImage");
b.Navigation("ListRunePages");
b.Navigation("Skins");
});
modelBuilder.Entity("EntityFrameWorkLib.RuneEntity", b =>
{
b.Navigation("ListRunePages");
});
modelBuilder.Entity("EntityFrameWorkLib.SkillEntity", b =>
{
b.Navigation("champions");
b.Navigation("LargeImageEntity");
});
#pragma warning restore 612, 618
}

@ -1,25 +1,20 @@
using System;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using Shared;
namespace EntityFrameWorkLib
{
public class RuneEntity
{
public class RuneEntity
{
[Key]
//[MaxLength(256)]
public string? Name { get; set; }
[MaxLength(256)]
public string Name { get; set; }
//[Required]
[Required]
[MaxLength(500)]
public string? Description { get; set; }
public string Description { get; set; }
//[Required]
[Required]
public RuneFamily RuneFamily { get; set; }
public Collection<RunePageEntity>? ListRunePages { get; set; }
}
}

@ -1,20 +0,0 @@
using System;
namespace EntityFrameWorkLib
{
public class RunePageEntity
{
public int Id { get; set; }
public String? Name { get; set; }
}
public enum Category
{
Major,
Minor1,
Minor2,
Minor3,
OtherMinor1,
OtherMinor2
}
}

@ -1,5 +1,4 @@
using System;
using Shared;
using System.ComponentModel.DataAnnotations;
namespace EntityFrameWorkLib
@ -8,16 +7,14 @@ namespace EntityFrameWorkLib
{
[Key]
[MaxLength(256)]
public string? Name { get; set; }
public string Name { get; set; }
//[Required]
[Required]
[MaxLength(500)]
public string? Description { get; set; }
public string Description { get; set; }
//[Required]
[Required]
public SkillType SkillType { get; set; }
public HashSet<ChampionEntity>? champions { get; set; }
}
}

@ -7,16 +7,16 @@ namespace EntityFrameWorkLib
{
[Key]
[MaxLength(256)]
public string? Name { get; set; }
public string Name { get; set; }
//[Required]
[Required]
[MaxLength(500)]
public string? Description { get; set; }
public string Description { get; set; }
public string? Icon { get; set; }
public string Icon { get; set; }
//[Required]
public float Price { get; set; }
}
[Required]
public float Price { get; set; }
}
}

@ -0,0 +1,15 @@
using System;
namespace EntityFrameWorkLib
{
public enum ChampionClass
{
Unknown,
Assassin,
Fighter,
Mage,
Marksman,
Support,
Tank,
}
}

@ -0,0 +1,11 @@
using System;
namespace EntityFrameWorkLib
{
public enum RuneFamily
{
Unknown,
Precision,
Domination
}
}

@ -0,0 +1,12 @@
using System;
namespace EntityFrameWorkLib
{
public enum SkillType
{
Unknown,
Basic,
Passive,
Ultimate
}
}

@ -1,98 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 25.0.1704.2
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{2960F9BA-49DE-494D-92E3-CE5A794BA1A9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{C76D0C23-1FFA-4963-93CD-E12BD643F030}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTests", "Tests\ConsoleTests\ConsoleTests.csproj", "{1889FA6E-B7C6-416E-8628-9449FB9070B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{3B720C0C-53FE-4642-A2DB-87FD8634CD74}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Stub", "Stub", "{2C607793-B163-4731-A4D1-AFE8A7C4C170}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubLib", "StubLib\StubLib.csproj", "{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleDB", "Tests\ConsoleDB\ConsoleDB.csproj", "{3E16421B-7372-477D-A25E-8249D5203A1E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUnitaireLOL", "Tests\TestUnitaireLOL\TestUnitaireLOL.csproj", "{F4473EB6-6CD7-4A73-89BC-82C247A23412}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbDatamanager", "DbDatamanager\DbDatamanager.csproj", "{B316E0A6-491B-45D6-A4E5-78AB662ABE1B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameWorkLib", "EntityFrameWorkLib\EntityFrameWorkLib.csproj", "{C78F459C-A1CE-4978-A08D-73C6BDB4094C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiLol", "WebApiLol\WebApiLol.csproj", "{DAE3B5A2-8904-43AE-8459-ED64C3366FDF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{73142960-0D40-4766-973B-37094F4BD879}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTestapi", "Tests\ConsoleTestapi\ConsoleTestapi.csproj", "{EA884D64-6425-46FB-BA25-E2EB8FE6BECE}"
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{1B81A541-7D10-4603-B5A2-94108954D831}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2960F9BA-49DE-494D-92E3-CE5A794BA1A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2960F9BA-49DE-494D-92E3-CE5A794BA1A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2960F9BA-49DE-494D-92E3-CE5A794BA1A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2960F9BA-49DE-494D-92E3-CE5A794BA1A9}.Release|Any CPU.Build.0 = Release|Any CPU
{1889FA6E-B7C6-416E-8628-9449FB9070B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1889FA6E-B7C6-416E-8628-9449FB9070B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1889FA6E-B7C6-416E-8628-9449FB9070B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1889FA6E-B7C6-416E-8628-9449FB9070B9}.Release|Any CPU.Build.0 = Release|Any CPU
{3B720C0C-53FE-4642-A2DB-87FD8634CD74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B720C0C-53FE-4642-A2DB-87FD8634CD74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B720C0C-53FE-4642-A2DB-87FD8634CD74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B720C0C-53FE-4642-A2DB-87FD8634CD74}.Release|Any CPU.Build.0 = Release|Any CPU
{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}.Release|Any CPU.Build.0 = Release|Any CPU
{3E16421B-7372-477D-A25E-8249D5203A1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E16421B-7372-477D-A25E-8249D5203A1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E16421B-7372-477D-A25E-8249D5203A1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E16421B-7372-477D-A25E-8249D5203A1E}.Release|Any CPU.Build.0 = Release|Any CPU
{F4473EB6-6CD7-4A73-89BC-82C247A23412}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F4473EB6-6CD7-4A73-89BC-82C247A23412}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4473EB6-6CD7-4A73-89BC-82C247A23412}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4473EB6-6CD7-4A73-89BC-82C247A23412}.Release|Any CPU.Build.0 = Release|Any CPU
{B316E0A6-491B-45D6-A4E5-78AB662ABE1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B316E0A6-491B-45D6-A4E5-78AB662ABE1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B316E0A6-491B-45D6-A4E5-78AB662ABE1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B316E0A6-491B-45D6-A4E5-78AB662ABE1B}.Release|Any CPU.Build.0 = Release|Any CPU
{C78F459C-A1CE-4978-A08D-73C6BDB4094C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C78F459C-A1CE-4978-A08D-73C6BDB4094C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C78F459C-A1CE-4978-A08D-73C6BDB4094C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C78F459C-A1CE-4978-A08D-73C6BDB4094C}.Release|Any CPU.Build.0 = Release|Any CPU
{DAE3B5A2-8904-43AE-8459-ED64C3366FDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DAE3B5A2-8904-43AE-8459-ED64C3366FDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DAE3B5A2-8904-43AE-8459-ED64C3366FDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DAE3B5A2-8904-43AE-8459-ED64C3366FDF}.Release|Any CPU.Build.0 = Release|Any CPU
{EA884D64-6425-46FB-BA25-E2EB8FE6BECE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA884D64-6425-46FB-BA25-E2EB8FE6BECE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA884D64-6425-46FB-BA25-E2EB8FE6BECE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA884D64-6425-46FB-BA25-E2EB8FE6BECE}.Release|Any CPU.Build.0 = Release|Any CPU
{1B81A541-7D10-4603-B5A2-94108954D831}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B81A541-7D10-4603-B5A2-94108954D831}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B81A541-7D10-4603-B5A2-94108954D831}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B81A541-7D10-4603-B5A2-94108954D831}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9}
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1889FA6E-B7C6-416E-8628-9449FB9070B9} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {2C607793-B163-4731-A4D1-AFE8A7C4C170}
{3E16421B-7372-477D-A25E-8249D5203A1E} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
{F4473EB6-6CD7-4A73-89BC-82C247A23412} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
{EA884D64-6425-46FB-BA25-E2EB8FE6BECE} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
EndGlobalSection
EndGlobal

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:shared="clr-namespace:Shared;assembly=Shared"
xmlns:model="clr-namespace:Model;assembly=Model"
x:Class="LolApp.ContentViews.ChampionClassSelector"
x:Name="root">
<ContentView.Resources>
<shared:ChampionClass x:Key="assassin">Assassin</shared:ChampionClass>
<shared:ChampionClass x:Key="fighter">Fighter</shared:ChampionClass>
<shared:ChampionClass x:Key="mage">Mage</shared:ChampionClass>
<shared:ChampionClass x:Key="marksman">Marksman</shared:ChampionClass>
<shared:ChampionClass x:Key="support">Support</shared:ChampionClass>
<shared:ChampionClass x:Key="tank">Tank</shared:ChampionClass>
<model:ChampionClass x:Key="assassin">Assassin</model:ChampionClass>
<model:ChampionClass x:Key="fighter">Fighter</model:ChampionClass>
<model:ChampionClass x:Key="mage">Mage</model:ChampionClass>
<model:ChampionClass x:Key="marksman">Marksman</model:ChampionClass>
<model:ChampionClass x:Key="support">Support</model:ChampionClass>
<model:ChampionClass x:Key="tank">Tank</model:ChampionClass>
<ControlTemplate x:Key="RadioButtonTemplate">
<Border Stroke="{StaticResource Transparent}"

@ -1,5 +1,4 @@
using Model;
using Shared;
namespace LolApp.ContentViews;

@ -91,7 +91,9 @@
<ProjectReference Include="..\StubLib\StubLib.csproj">
<ReferenceSourceTarget></ReferenceSourceTarget>
</ProjectReference>
<ProjectReference Include="..\ViewModels\ViewModels.csproj" />
<ProjectReference Include="..\ViewModels\ViewModels.csproj">
<ReferenceSourceTarget></ReferenceSourceTarget>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="5.0.0" />

@ -1,7 +1,6 @@
using System;
using System.Globalization;
using Model;
using Shared;
namespace LolApp.Resources.Converters
{

@ -3,8 +3,8 @@ using System.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Model;
using Shared;
using ViewModels;
namespace LolApp.ViewModels
{
public partial class AddSkillVM : ObservableObject

@ -2,7 +2,6 @@
using System.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
using Model;
using Shared;
namespace LolApp.ViewModels
{

@ -3,10 +3,8 @@ using System.Reflection;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Model;
using Shared;
using ViewModels;
namespace LolApp.ViewModels
{
[ObservableObject]

@ -2,7 +2,6 @@
using System.Collections.ObjectModel;
using System.Numerics;
using System.Text;
using Shared;
namespace Model;
public class Champion : IEquatable<Champion>

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

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

@ -1,5 +1,5 @@
using System;
using Shared;
namespace Model
{
public class Skill : IEquatable<Skill>

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

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

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

@ -6,10 +6,4 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<None Remove="enums\" />
</ItemGroup>
<ItemGroup>
<Folder Include="enums\" />
</ItemGroup>
</Project>

@ -1,6 +1,5 @@
using System;
using Model;
using Shared;
namespace StubLib
{
@ -14,6 +13,7 @@ namespace StubLib
new Champion("Akshan", ChampionClass.Marksman),
new Champion("Bard", ChampionClass.Support),
new Champion("Alistar", ChampionClass.Tank),
new Champion("Kindred", ChampionClass.Marksman)
};
public class ChampionsManager : IChampionsManager

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

File diff suppressed because one or more lines are too long

@ -4,7 +4,6 @@ using Microsoft.Extensions.DependencyInjection;
using Model;
using StubLib;
using static System.Console;
using Shared;
namespace ConsoleTests
{

@ -1,40 +0,0 @@
using System;
using Microsoft.Extensions.Logging.Abstractions;
using StubLib;
using WebApiLol;
using WebApiLol.Controllers;
namespace TestUnitaireLOL
{
public class TestAPI
{
//[Theory]
//[InlineData("Beatrice", "sdfsdfd", "icon.png")]
//[InlineData("Maurice", "Ahri est un champion de League of Legends", "icon.png")]
//[InlineData("Loupiotte", "Akali est un champion de League of Legends", "icon.png")]
//public async Task TestPostChampion(string name, string bio, string icon)
//{
// // Arrange
// var data = new StubData();
// var logger = new NullLogger<ChampionController>();
// var controller = new ChampionController(data, logger);
// var champDTO = new ChampionDTO()
// {
// Name = name,
// Bio = bio,
// Icon = icon
// };
// // Act
// var nbInListBefore = data.ChampionsMgr.GetNbItems().Result;
// var result = await controller.AddChampion(champDTO);
// var nbInListAfter = data.ChampionsMgr.GetNbItems().Result;
// // Assert
// // IS the champion added to the list, number of champions in the list + 1
// Assert.Equal(nbInListBefore + 1, nbInListAfter);
// // Test le code de retour
//}
}
}

@ -1,178 +0,0 @@
using System;
using System.Collections.ObjectModel;
using EntityFrameWorkLib;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Model;
using Shared;
namespace TestUnitaireLOL
{
public class TestEf
{
//[Theory]
//[InlineData(0, "Zeus", "Dieu de la foudre", true)]
//[InlineData(10, "Hades", "Dieu des enfers", true)]
//[InlineData(1, "Aphrodite", "Déesse de l'amour", true)]
////[InlineData(10, "AresAresAresAresAresAresAresAresAresAres",
//// "Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre" +
//// "Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre" +
//// "Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre", false)]
//public async Task TestAddChampionInMemory(int id, String name, String bio, bool expected)
//{
// var connection = new SqliteConnection("DataSource=:memory:");
// connection.Open();
// var options = new DbContextOptionsBuilder<LolContext>()
// .UseSqlite(connection)
// .Options;
// using (var context = new LolContext(options))
// {
// await context.Database.EnsureCreatedAsync();
// SkinEntity black = new SkinEntity { Name = "Black", Description = "Black skin", Icon = "black.png", Price = 0.99f };
// SkinEntity white = new SkinEntity { Name = "White", Description = "White skin", Icon = "white.png", Price = 150.99f };
// SkinEntity green = new SkinEntity { Name = "Green", Description = "Green skin", Icon = "green.png", Price = 4.99f };
// RunePageEntity runePage1 = new RunePageEntity { Id = 1, Name = "runepage1" };
// var Dieu = new ChampionEntity
// {
// UniqueId = id,
// Name = name,
// Bio = bio,
// Skins = new Collection<SkinEntity>(new List<SkinEntity> { black, white, green }),
// ListRunePages = new Collection<RunePageEntity>(new List<RunePageEntity> { { runePage1 } })
// };
// ChampionEntity found = await context.Champions.SingleOrDefaultAsync(c => c.Name == "Zeus");
// Assert.Null(found);
// await context.Champions.AddAsync(Dieu);
// await context.SaveChangesAsync();
// found = await context.Champions.SingleOrDefaultAsync(c => c.Name == name);
// Assert.NotNull(found);
// Assert.Equal(1, await context.Champions.CountAsync());
// Assert.Equal(name, found.Name);
// Assert.Equal(3, found.Skins.Count);
// Assert.Equal(1, found.ListRunePages.Count);
// // Test if the max length of the name is respected (30) and the max length of the bio is respected (256)
// if (expected)
// {
// Assert.True(found.Name.Length <= 30);
// Assert.True(found.Bio.Length <= 256);
// }
// else
// {
// Assert.False(found.Name.Length <= 30);
// Assert.False(found.Bio.Length <= 256);
// }
// }
//}
[Fact]
public void TestModifyChampionInMemory()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<LolContext>()
.UseSqlite(connection)
.Options;
//prepares the database with one instance of the context
using (var context = new LolContext(options))
{
//context.Database.OpenConnection();
context.Database.EnsureCreated();
ChampionEntity chewie = new ChampionEntity { Name = "Chewbacca",Icon="Icon1", Bio = "Zeus is the king of the gods." };
ChampionEntity yoda = new ChampionEntity { Name = "Yoda",Icon="Icon2", Bio = "Zeus is the king of the gods." };
ChampionEntity ewok = new ChampionEntity { Name = "Ewok",Icon="Icon3", Bio = "Zeus is the king of the gods." };
context.Champions.Add(chewie);
context.Champions.Add(yoda);
context.Champions.Add(ewok);
context.SaveChanges();
}
//uses another instance of the context to do the tests
using (var context = new LolContext(options))
{
context.Database.EnsureCreated();
string nameToFind = "ew";
Assert.Equal(2, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count());
nameToFind = "wo";
Assert.Equal(1, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count());
var ewok = context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).First();
ewok.Name = "Wicket";
context.SaveChanges();
}
//uses another instance of the context to do the tests
using (var context = new LolContext(options))
{
context.Database.EnsureCreated();
string nameToFind = "ew";
Assert.Equal(1, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count());
nameToFind = "wick";
Assert.Equal(1, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count());
}
}
//[Theory]
//[InlineData(0, "black", "super Skin", "icon1.png", 190000000.2f, true)]
//[InlineData(1, "White", "skin1", "icon1", 19, true)]
//[InlineData(2, "Green", "skin", "icon1.jpg", -1, false)]
//public async Task TestAddSkinToChampionInMemory(int id, String name, String description, String icon, float price, bool expected)
//{
// var connection = new SqliteConnection("DataSource=:memory:");
// connection.Open();
// var options = new DbContextOptionsBuilder<LolContext>()
// .UseSqlite(connection)
// .Options;
// using (var context = new LolContext(options))
// {
// await context.Database.EnsureCreatedAsync();
// var Dieu = new ChampionEntity
// {
// UniqueId = 0,
// Name = "Zeus",
// Bio = "Dieu de la foudre",
// Skins = new Collection<SkinEntity>()
// };
// SkinEntity item = new SkinEntity
// {
// Name = name,
// Description = description,
// Icon = icon,
// Price = price
// };
// Dieu.Skins.Add(item);
// ChampionEntity found = await context.Champions.SingleOrDefaultAsync(c => c.Name == "Zeus");
// Assert.Null(found);
// await context.Champions.AddAsync(Dieu);
// await context.SaveChangesAsync();
// found = await context.Champions.SingleOrDefaultAsync(c => c.Name == name);
// }
//}
}
}

@ -20,10 +20,6 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
@ -32,7 +28,5 @@
<ItemGroup>
<ProjectReference Include="..\..\EntityFrameWorkLib\EntityFrameWorkLib.csproj" />
<ProjectReference Include="..\..\DbDatamanager\DbDatamanager.csproj" />
<ProjectReference Include="..\..\StubLib\StubLib.csproj" />
<ProjectReference Include="..\..\WebApiLol\WebApiLol.csproj" />
</ItemGroup>
</Project>

@ -1,30 +1,9 @@
using System;
using EntityFrameWorkLib;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
namespace TestUnitaireLOL
{
public class UnitTestDbDataManager
{
public void Test_Data_AddItem(int expectedResult,
IEnumerable<ChampionEntity> expectedChampions,
IEnumerable<ChampionEntity> expectedChampionsAdded,
params ChampionEntity[] championsToAdd)
{
var connexion = new SqliteConnection("DataSource=:memory:");
connexion.Open();
var options = new DbContextOptionsBuilder<LolContext>()
.UseSqlite(connexion)
.Options;
using (var context = new LolContext())
{
}
}
}
}
}

@ -3,7 +3,6 @@ using CommunityToolkit.Mvvm.ComponentModel;
using Model;
using Microsoft.Maui.Controls;
using System.Collections.ObjectModel;
using Shared;
namespace ViewModels

@ -6,7 +6,6 @@ using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.Input;
using System.Data.SqlTypes;
using System.Reflection;
using Shared;
namespace ViewModels;

@ -3,7 +3,6 @@ using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Model;
using Shared;
namespace ViewModels
{

@ -1,7 +1,6 @@
using System;
using CommunityToolkit.Mvvm.ComponentModel;
using Model;
using Shared;
namespace ViewModels
{

@ -8,7 +8,9 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\Model\Model.csproj">
<ReferenceSourceTarget></ReferenceSourceTarget>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />

@ -3,6 +3,7 @@ namespace WebApiLol
{
public class ChampionDTO
{
public int UniqueId { get; set; }
public string Name { get; set; }

@ -1,15 +0,0 @@
using System;
namespace WebApiLol
{
public class ChampionPageDTO
{
public IEnumerable<ChampionDTO> Data { get; set; }
public int Index { get; set; }
public int Count { get; set; }
public int TotalCount { get; set; }
}
}

@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
using WebApiLol.Converter;
@ -17,38 +14,21 @@ public class ChampionController : ControllerBase
{
private StubData.ChampionsManager ChampionsManager { get; set; } = new StubData.ChampionsManager(new StubData());
private IChampionsManager _dataManager;
private readonly ILogger<ChampionController> _logger;
public ChampionController(IDataManager manager,ILogger<ChampionController> logger)
public ChampionController(ILogger<ChampionController> logger)
{
_dataManager = manager.ChampionsMgr;
_logger = logger;
}
[HttpGet]
[ProducesResponseType(typeof(ChampionPageDTO), 200)]
public async Task<IActionResult> Get([FromQuery] int index = 0, int count = 10, string? name = "")
public async Task<IActionResult> Get()
{
_logger.LogInformation($"methode Get de ControllerChampions appelée");
int nbChampions = await _dataManager.GetNbItems();
_logger.LogInformation($"Nombre de champions : {nbChampions}");
var champs = (await _dataManager.GetItemsByName(name, index, int.MaxValue))
.Where(champ => string.IsNullOrEmpty(name) || champ.Name.Contains(name, StringComparison.InvariantCultureIgnoreCase))
.Take(count)
.Select(Model => Model.toDTO());
var page = new ChampionPageDTO
{
Data = champs,
Index = index,
Count = champs.Count(),
TotalCount = nbChampions
};
return Ok(page);
var list = await ChampionsManager.GetItems(0, await ChampionsManager.GetNbItems());
return Ok(list.Select(champion => champion?.toDTO()));
}
[HttpGet("name")]
[HttpGet("{name}")]
public async Task<IActionResult> GetById(string name)
{
var championSelected = await ChampionsManager.GetItemsByName(name, 0, await ChampionsManager.GetNbItemsByName(name), null);
@ -89,15 +69,15 @@ public class ChampionController : ControllerBase
}
[HttpDelete("Delete")]
public async Task<IActionResult> DeleteChampion(string name)
public async Task<IActionResult> DeleteChampion(ChampionDTO champion)
{
var championSelected = await ChampionsManager.GetItemsByName(name, 0, await ChampionsManager.GetNbItemsByName(name), null);
var championSelected = await ChampionsManager.GetItemsByName(champion.toModel().Name, 0, await ChampionsManager.GetNbItemsByName(champion.toModel().Name), null);
if (!await ChampionsManager.DeleteItem(championSelected.FirstOrDefault()))
{
Console.WriteLine("champion { " + name + " } non trouvé !");
Console.WriteLine("champion { " + champion.toModel().Name + " } non trouvé !");
return NotFound();
}
Console.WriteLine("champion { " + name + " } supprimé");
Console.WriteLine("champion { " + champion.toModel().Name + " } supprimé");
return Ok();
}

@ -0,0 +1,33 @@
//using Microsoft.AspNetCore.Mvc;
//namespace WebApiLol.Controllers;
//[ApiController]
//[Route("[controller]")]
//public class WeatherForecastController : ControllerBase
//{
// private static readonly string[] Summaries = new[]
// {
// "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
// };
// private readonly ILogger<WeatherForecastController> _logger;
// public WeatherForecastController(ILogger<WeatherForecastController> logger)
// {
// _logger = logger;
// }
// [HttpGet(Name = "GetWeatherForecast")]
// public IEnumerable<> Get()
// {
// return Enumerable.Range(1, 5).Select(index => new WeatherForecast
// {
// Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
// TemperatureC = Random.Shared.Next(-20, 55),
// Summary = Summaries[Random.Shared.Next(Summaries.Length)]
// })
// .ToArray();
// }
//}
Loading…
Cancel
Save