From 9c860adb90a6b8e25ad0b002884eeb56b0e05800 Mon Sep 17 00:00:00 2001 From: Garrigue Benjamin <93991961+Wyveth@users.noreply.github.com> Date: Tue, 12 Dec 2023 01:33:05 +0100 Subject: [PATCH] Setting up a GUID for the tables. --- .../Abstract/Identity.cs | 2 + .../Interface/ITIdentity.cs | 2 + .../20231211221542_AddGuid.Designer.cs | 1958 +++++++++++++++++ .../Migrations/20231211221542_AddGuid.cs | 251 +++ .../ScrapingContextModelSnapshot.cs | 63 + .../Repository/Class/AttaqueRepository.cs | 5 + .../Repository/Class/DataInfoRepository.cs | 26 +- .../Repository/Class/PokemonRepository.cs | 38 +- .../Repository/GenericClass/Repository.cs | 26 +- .../Settings/appSettings.json | 2 +- .../Controllers/Abstract/GenericController.cs | 22 + .../Controllers/MigrationController.cs | 86 + .../appsettings.Development.json | 2 +- WepApiScrapingData/appsettings.json | 2 +- 14 files changed, 2442 insertions(+), 43 deletions(-) create mode 100644 WebApiScrapingData.Infrastructure/Migrations/20231211221542_AddGuid.Designer.cs create mode 100644 WebApiScrapingData.Infrastructure/Migrations/20231211221542_AddGuid.cs create mode 100644 WepApiScrapingData/Controllers/MigrationController.cs diff --git a/WebApiScrapingData.Domain/Abstract/Identity.cs b/WebApiScrapingData.Domain/Abstract/Identity.cs index 5671800..bba796d 100644 --- a/WebApiScrapingData.Domain/Abstract/Identity.cs +++ b/WebApiScrapingData.Domain/Abstract/Identity.cs @@ -12,6 +12,8 @@ public abstract class Identity : ITIdentity [DataMember(Name = DataMember.Id)] public long Id { get; set; } + public Guid Guid { get; set; } + public string? UserCreation { get; set; } public DateTime DateCreation { get; set; } diff --git a/WebApiScrapingData.Domain/Interface/ITIdentity.cs b/WebApiScrapingData.Domain/Interface/ITIdentity.cs index ec809ba..6e57a1b 100644 --- a/WebApiScrapingData.Domain/Interface/ITIdentity.cs +++ b/WebApiScrapingData.Domain/Interface/ITIdentity.cs @@ -9,6 +9,8 @@ namespace WebApiScrapingData.Domain.Interface public interface ITIdentity { public long Id { get; set; } + + public Guid Guid { get; set; } public string? UserCreation { get; set; } diff --git a/WebApiScrapingData.Infrastructure/Migrations/20231211221542_AddGuid.Designer.cs b/WebApiScrapingData.Infrastructure/Migrations/20231211221542_AddGuid.Designer.cs new file mode 100644 index 0000000..ad359a1 --- /dev/null +++ b/WebApiScrapingData.Infrastructure/Migrations/20231211221542_AddGuid.Designer.cs @@ -0,0 +1,1958 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebApiScrapingData.Infrastructure.Data; + +#nullable disable + +namespace WebApiScrapingData.Infrastructure.Migrations +{ + [DbContext(typeof(ScrapingContext))] + [Migration("20231211221542_add-guid")] + partial class AddGuid + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.12") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Attaque", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Description_CN") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_CO") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_DE") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_EN") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_ES") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_FR") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_IT") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_JP") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_RU") + .HasColumnType("nvarchar(max)"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("Name_CN") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_CO") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_DE") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_EN") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_ES") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_FR") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_IT") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_JP") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_RU") + .HasColumnType("nvarchar(max)"); + + b.Property("PP") + .HasColumnType("nvarchar(max)"); + + b.Property("Power") + .HasColumnType("nvarchar(max)"); + + b.Property("Precision") + .HasColumnType("nvarchar(max)"); + + b.Property("TypeAttaqueId") + .HasColumnType("bigint"); + + b.Property("TypePokId") + .HasColumnType("bigint"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TypeAttaqueId"); + + b.HasIndex("TypePokId"); + + b.ToTable("Attaques"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.DataInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .HasColumnType("nvarchar(max)"); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("DescriptionTalent") + .HasColumnType("nvarchar(max)"); + + b.Property("DescriptionVx") + .HasColumnType("nvarchar(max)"); + + b.Property("DescriptionVy") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("Evolutions") + .HasColumnType("nvarchar(max)"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("NextUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("Size") + .HasColumnType("nvarchar(max)"); + + b.Property("Talent") + .HasColumnType("nvarchar(max)"); + + b.Property("Types") + .HasColumnType("nvarchar(max)"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("Weakness") + .HasColumnType("nvarchar(max)"); + + b.Property("Weight") + .HasColumnType("nvarchar(max)"); + + b.Property("WhenEvolution") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("DataInfos"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Game", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("Name_CN") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_CO") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_DE") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_EN") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_ES") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_FR") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_IT") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_JP") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_RU") + .HasColumnType("nvarchar(max)"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Games"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Pokemon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("BasicHappiness") + .HasColumnType("nvarchar(max)"); + + b.Property("CaptureRate") + .HasColumnType("nvarchar(max)"); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("EggMoves") + .HasColumnType("nvarchar(max)"); + + b.Property("GameId") + .HasColumnType("bigint"); + + b.Property("Generation") + .HasColumnType("int"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("Id_CN") + .HasColumnType("bigint"); + + b.Property("Id_CO") + .HasColumnType("bigint"); + + b.Property("Id_DE") + .HasColumnType("bigint"); + + b.Property("Id_EN") + .HasColumnType("bigint"); + + b.Property("Id_ES") + .HasColumnType("bigint"); + + b.Property("Id_FR") + .HasColumnType("bigint"); + + b.Property("Id_IT") + .HasColumnType("bigint"); + + b.Property("Id_JP") + .HasColumnType("bigint"); + + b.Property("Id_RU") + .HasColumnType("bigint"); + + b.Property("Number") + .HasColumnType("nvarchar(max)"); + + b.Property("PathImg") + .HasColumnType("nvarchar(max)"); + + b.Property("PathSound") + .HasColumnType("nvarchar(max)"); + + b.Property("PathSprite") + .HasColumnType("nvarchar(max)"); + + b.Property("StatAttaque") + .HasColumnType("int"); + + b.Property("StatAttaqueSpe") + .HasColumnType("int"); + + b.Property("StatDefense") + .HasColumnType("int"); + + b.Property("StatDefenseSpe") + .HasColumnType("int"); + + b.Property("StatPv") + .HasColumnType("int"); + + b.Property("StatTotal") + .HasColumnType("int"); + + b.Property("StatVitesse") + .HasColumnType("int"); + + b.Property("TypeEvolution") + .HasColumnType("nvarchar(max)"); + + b.Property("UrlImg") + .HasColumnType("nvarchar(max)"); + + b.Property("UrlSound") + .HasColumnType("nvarchar(max)"); + + b.Property("UrlSprite") + .HasColumnType("nvarchar(max)"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("GameId"); + + b.HasIndex("Id_CN"); + + b.HasIndex("Id_CO"); + + b.HasIndex("Id_DE"); + + b.HasIndex("Id_EN"); + + b.HasIndex("Id_ES"); + + b.HasIndex("Id_FR"); + + b.HasIndex("Id_IT"); + + b.HasIndex("Id_JP"); + + b.HasIndex("Id_RU"); + + b.ToTable("Pokemons"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Pokemon_Attaque", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AttaqueId") + .HasColumnType("bigint"); + + b.Property("CTCS") + .HasColumnType("nvarchar(max)"); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("Level") + .HasColumnType("nvarchar(max)"); + + b.Property("PokemonId") + .HasColumnType("bigint"); + + b.Property("TypeLearn") + .HasColumnType("nvarchar(max)"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AttaqueId"); + + b.HasIndex("PokemonId"); + + b.ToTable("Pokemon_Attaque"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Pokemon_Talent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("IsHidden") + .HasColumnType("bit"); + + b.Property("PokemonId") + .HasColumnType("bigint"); + + b.Property("TalentId") + .HasColumnType("bigint"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PokemonId"); + + b.HasIndex("TalentId"); + + b.ToTable("Pokemon_Talent"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Pokemon_TypePok", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("PokemonId") + .HasColumnType("bigint"); + + b.Property("TypePokId") + .HasColumnType("bigint"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PokemonId"); + + b.HasIndex("TypePokId"); + + b.ToTable("Pokemon_TypePok"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Pokemon_Weakness", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("PokemonId") + .HasColumnType("bigint"); + + b.Property("TypePokId") + .HasColumnType("bigint"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PokemonId"); + + b.HasIndex("TypePokId"); + + b.ToTable("Pokemon_Weakness"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.Answer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("IsCorrect") + .HasColumnType("bit"); + + b.Property("IsSelected") + .HasColumnType("bit"); + + b.Property("Libelle") + .HasColumnType("nvarchar(max)"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("nvarchar(max)"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Answers"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.Difficulty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Code") + .HasColumnType("nvarchar(max)"); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("Libelle_CN") + .HasColumnType("nvarchar(max)"); + + b.Property("Libelle_CO") + .HasColumnType("nvarchar(max)"); + + b.Property("Libelle_DE") + .HasColumnType("nvarchar(max)"); + + b.Property("Libelle_EN") + .HasColumnType("nvarchar(max)"); + + b.Property("Libelle_ES") + .HasColumnType("nvarchar(max)"); + + b.Property("Libelle_FR") + .HasColumnType("nvarchar(max)"); + + b.Property("Libelle_IT") + .HasColumnType("nvarchar(max)"); + + b.Property("Libelle_JP") + .HasColumnType("nvarchar(max)"); + + b.Property("Libelle_RU") + .HasColumnType("nvarchar(max)"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Difficulties"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.Question", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DataObjectID") + .HasColumnType("int"); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Done") + .HasColumnType("bit"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("QuestionTypeId") + .HasColumnType("bigint"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("QuestionTypeId"); + + b.ToTable("Questions"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.Question_Answer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AnswerId") + .HasColumnType("bigint"); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("QuestionId") + .HasColumnType("bigint"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AnswerId"); + + b.HasIndex("QuestionId"); + + b.ToTable("Question_Answer"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.QuestionAnswer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("QuestionId") + .HasColumnType("bigint"); + + b.Property("QuizzId") + .HasColumnType("bigint"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("QuestionId"); + + b.HasIndex("QuizzId"); + + b.ToTable("QuestionAnswers"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.QuestionAnswer_Answer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AnswerId") + .HasColumnType("bigint"); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("QuestionAnswerId") + .HasColumnType("bigint"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AnswerId"); + + b.HasIndex("QuestionAnswerId"); + + b.ToTable("QuestionAnswer_Answer"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.QuestionType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Code") + .HasColumnType("nvarchar(max)"); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("DifficultyId") + .HasColumnType("bigint"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("IsBlurred") + .HasColumnType("bit"); + + b.Property("IsGrayscale") + .HasColumnType("bit"); + + b.Property("IsHide") + .HasColumnType("bit"); + + b.Property("IsMultipleAnswers") + .HasColumnType("bit"); + + b.Property("IsSameType") + .HasColumnType("bit"); + + b.Property("Libelle") + .HasColumnType("nvarchar(max)"); + + b.Property("NbAnswers") + .HasColumnType("int"); + + b.Property("NbAnswersPossible") + .HasColumnType("int"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DifficultyId"); + + b.ToTable("QuestionTypes"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.Quizz", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Done") + .HasColumnType("bit"); + + b.Property("Easy") + .HasColumnType("bit"); + + b.Property("Gen1") + .HasColumnType("bit"); + + b.Property("Gen2") + .HasColumnType("bit"); + + b.Property("Gen3") + .HasColumnType("bit"); + + b.Property("Gen4") + .HasColumnType("bit"); + + b.Property("Gen5") + .HasColumnType("bit"); + + b.Property("Gen6") + .HasColumnType("bit"); + + b.Property("Gen7") + .HasColumnType("bit"); + + b.Property("Gen8") + .HasColumnType("bit"); + + b.Property("GenArceus") + .HasColumnType("bit"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("Hard") + .HasColumnType("bit"); + + b.Property("IdentityUserId") + .HasColumnType("nvarchar(450)"); + + b.Property("Normal") + .HasColumnType("bit"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IdentityUserId"); + + b.ToTable("Quizzs"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.Quizz_Question", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("QuestionId") + .HasColumnType("bigint"); + + b.Property("QuizzId") + .HasColumnType("bigint"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("QuestionId"); + + b.HasIndex("QuizzId"); + + b.ToTable("Quizz_Question"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.QuizzDifficulty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Easy") + .HasColumnType("bit"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("Hard") + .HasColumnType("bit"); + + b.Property("Normal") + .HasColumnType("bit"); + + b.Property("QuizzId") + .HasColumnType("bigint"); + + b.Property("ResumeQuestion") + .HasColumnType("nvarchar(max)"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("QuizzId"); + + b.ToTable("QuizzDifficulties"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Talent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Description_CN") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_CO") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_DE") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_EN") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_ES") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_FR") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_IT") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_JP") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_RU") + .HasColumnType("nvarchar(max)"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("Name_CN") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_CO") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_DE") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_EN") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_ES") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_FR") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_IT") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_JP") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_RU") + .HasColumnType("nvarchar(max)"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Talents"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.TypeAttaque", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Description_CN") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_CO") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_DE") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_EN") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_ES") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_FR") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_IT") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_JP") + .HasColumnType("nvarchar(max)"); + + b.Property("Description_RU") + .HasColumnType("nvarchar(max)"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("Name_CN") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_CO") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_DE") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_EN") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_ES") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_FR") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_IT") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_JP") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_RU") + .HasColumnType("nvarchar(max)"); + + b.Property("PathImg") + .HasColumnType("nvarchar(max)"); + + b.Property("UrlImg") + .HasColumnType("nvarchar(max)"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("TypeAttaques"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.TypePok", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DateCreation") + .HasColumnType("datetime2"); + + b.Property("DateModification") + .HasColumnType("datetime2"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("ImgColor") + .HasColumnType("nvarchar(max)"); + + b.Property("InfoColor") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_CN") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_CO") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_DE") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_EN") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_ES") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_FR") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_IT") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_JP") + .HasColumnType("nvarchar(max)"); + + b.Property("Name_RU") + .HasColumnType("nvarchar(max)"); + + b.Property("PathAutoHome") + .HasColumnType("nvarchar(max)"); + + b.Property("PathFondGo") + .HasColumnType("nvarchar(max)"); + + b.Property("PathIconHome") + .HasColumnType("nvarchar(max)"); + + b.Property("PathMiniGo") + .HasColumnType("nvarchar(max)"); + + b.Property("PathMiniHome_CN") + .HasColumnType("nvarchar(max)"); + + b.Property("PathMiniHome_CO") + .HasColumnType("nvarchar(max)"); + + b.Property("PathMiniHome_DE") + .HasColumnType("nvarchar(max)"); + + b.Property("PathMiniHome_EN") + .HasColumnType("nvarchar(max)"); + + b.Property("PathMiniHome_ES") + .HasColumnType("nvarchar(max)"); + + b.Property("PathMiniHome_FR") + .HasColumnType("nvarchar(max)"); + + b.Property("PathMiniHome_IT") + .HasColumnType("nvarchar(max)"); + + b.Property("PathMiniHome_JP") + .HasColumnType("nvarchar(max)"); + + b.Property("PathMiniHome_RU") + .HasColumnType("nvarchar(max)"); + + b.Property("TypeColor") + .HasColumnType("nvarchar(max)"); + + b.Property("UrlAutoHome") + .HasColumnType("nvarchar(max)"); + + b.Property("UrlFondGo") + .HasColumnType("nvarchar(max)"); + + b.Property("UrlIconHome") + .HasColumnType("nvarchar(max)"); + + b.Property("UrlMiniGo") + .HasColumnType("nvarchar(max)"); + + b.Property("UrlMiniHome") + .HasColumnType("nvarchar(max)"); + + b.Property("UserCreation") + .HasColumnType("nvarchar(max)"); + + b.Property("UserModification") + .HasColumnType("nvarchar(max)"); + + b.Property("versionModification") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("TypesPok"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Attaque", b => + { + b.HasOne("WebApiScrapingData.Domain.Class.TypeAttaque", "TypeAttaque") + .WithMany() + .HasForeignKey("TypeAttaqueId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("WebApiScrapingData.Domain.Class.TypePok", "TypePok") + .WithMany() + .HasForeignKey("TypePokId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("TypeAttaque"); + + b.Navigation("TypePok"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Pokemon", b => + { + b.HasOne("WebApiScrapingData.Domain.Class.Game", "Game") + .WithMany() + .HasForeignKey("GameId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("WebApiScrapingData.Domain.Class.DataInfo", "CN") + .WithMany() + .HasForeignKey("Id_CN") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.DataInfo", "CO") + .WithMany() + .HasForeignKey("Id_CO") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.DataInfo", "DE") + .WithMany() + .HasForeignKey("Id_DE") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.DataInfo", "EN") + .WithMany() + .HasForeignKey("Id_EN") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.DataInfo", "ES") + .WithMany() + .HasForeignKey("Id_ES") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.DataInfo", "FR") + .WithMany() + .HasForeignKey("Id_FR") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.DataInfo", "IT") + .WithMany() + .HasForeignKey("Id_IT") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.DataInfo", "JP") + .WithMany() + .HasForeignKey("Id_JP") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.DataInfo", "RU") + .WithMany() + .HasForeignKey("Id_RU") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CN"); + + b.Navigation("CO"); + + b.Navigation("DE"); + + b.Navigation("EN"); + + b.Navigation("ES"); + + b.Navigation("FR"); + + b.Navigation("Game"); + + b.Navigation("IT"); + + b.Navigation("JP"); + + b.Navigation("RU"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Pokemon_Attaque", b => + { + b.HasOne("WebApiScrapingData.Domain.Class.Attaque", "Attaque") + .WithMany("Pokemon_Attaques") + .HasForeignKey("AttaqueId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.Pokemon", "Pokemon") + .WithMany("Pokemon_Attaques") + .HasForeignKey("PokemonId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Attaque"); + + b.Navigation("Pokemon"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Pokemon_Talent", b => + { + b.HasOne("WebApiScrapingData.Domain.Class.Pokemon", "Pokemon") + .WithMany("Pokemon_Talents") + .HasForeignKey("PokemonId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.Talent", "Talent") + .WithMany("Pokemon_Talents") + .HasForeignKey("TalentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Pokemon"); + + b.Navigation("Talent"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Pokemon_TypePok", b => + { + b.HasOne("WebApiScrapingData.Domain.Class.Pokemon", "Pokemon") + .WithMany("Pokemon_TypePoks") + .HasForeignKey("PokemonId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.TypePok", "TypePok") + .WithMany("Pokemon_TypePoks") + .HasForeignKey("TypePokId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Pokemon"); + + b.Navigation("TypePok"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Pokemon_Weakness", b => + { + b.HasOne("WebApiScrapingData.Domain.Class.Pokemon", "Pokemon") + .WithMany("Pokemon_Weaknesses") + .HasForeignKey("PokemonId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.TypePok", "TypePok") + .WithMany("Pokemon_Weaknesses") + .HasForeignKey("TypePokId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Pokemon"); + + b.Navigation("TypePok"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.Question", b => + { + b.HasOne("WebApiScrapingData.Domain.Class.Quizz.QuestionType", "QuestionType") + .WithMany() + .HasForeignKey("QuestionTypeId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("QuestionType"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.Question_Answer", b => + { + b.HasOne("WebApiScrapingData.Domain.Class.Quizz.Answer", "Answer") + .WithMany() + .HasForeignKey("AnswerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.Quizz.Question", "Question") + .WithMany("Question_Answers") + .HasForeignKey("QuestionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Answer"); + + b.Navigation("Question"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.QuestionAnswer", b => + { + b.HasOne("WebApiScrapingData.Domain.Class.Quizz.Question", "Question") + .WithMany() + .HasForeignKey("QuestionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("WebApiScrapingData.Domain.Class.Quizz.Quizz", "Quizz") + .WithMany() + .HasForeignKey("QuizzId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Question"); + + b.Navigation("Quizz"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.QuestionAnswer_Answer", b => + { + b.HasOne("WebApiScrapingData.Domain.Class.Quizz.Answer", "Answer") + .WithMany() + .HasForeignKey("AnswerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.Quizz.QuestionAnswer", "QuestionAnswer") + .WithMany("QuestionAnswer_Answers") + .HasForeignKey("QuestionAnswerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Answer"); + + b.Navigation("QuestionAnswer"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.QuestionType", b => + { + b.HasOne("WebApiScrapingData.Domain.Class.Quizz.Difficulty", "Difficulty") + .WithMany() + .HasForeignKey("DifficultyId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Difficulty"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.Quizz", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "IdentityUser") + .WithMany() + .HasForeignKey("IdentityUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("IdentityUser"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.Quizz_Question", b => + { + b.HasOne("WebApiScrapingData.Domain.Class.Quizz.Question", "Question") + .WithMany() + .HasForeignKey("QuestionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("WebApiScrapingData.Domain.Class.Quizz.Quizz", "Quizz") + .WithMany("Quizz_Questions") + .HasForeignKey("QuizzId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Question"); + + b.Navigation("Quizz"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.QuizzDifficulty", b => + { + b.HasOne("WebApiScrapingData.Domain.Class.Quizz.Quizz", "Quizz") + .WithMany() + .HasForeignKey("QuizzId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Quizz"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Attaque", b => + { + b.Navigation("Pokemon_Attaques"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Pokemon", b => + { + b.Navigation("Pokemon_Attaques"); + + b.Navigation("Pokemon_Talents"); + + b.Navigation("Pokemon_TypePoks"); + + b.Navigation("Pokemon_Weaknesses"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.Question", b => + { + b.Navigation("Question_Answers"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.QuestionAnswer", b => + { + b.Navigation("QuestionAnswer_Answers"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Quizz.Quizz", b => + { + b.Navigation("Quizz_Questions"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.Talent", b => + { + b.Navigation("Pokemon_Talents"); + }); + + modelBuilder.Entity("WebApiScrapingData.Domain.Class.TypePok", b => + { + b.Navigation("Pokemon_TypePoks"); + + b.Navigation("Pokemon_Weaknesses"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebApiScrapingData.Infrastructure/Migrations/20231211221542_AddGuid.cs b/WebApiScrapingData.Infrastructure/Migrations/20231211221542_AddGuid.cs new file mode 100644 index 0000000..dc970a2 --- /dev/null +++ b/WebApiScrapingData.Infrastructure/Migrations/20231211221542_AddGuid.cs @@ -0,0 +1,251 @@ +using System.Linq; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.Extensions.Configuration; +using WebApiScrapingData.Infrastructure.Data; + +#nullable disable + +namespace WebApiScrapingData.Infrastructure.Migrations +{ + public partial class AddGuid : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Guid", + table: "TypesPok", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "TypeAttaques", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "Talents", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "Quizzs", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "QuizzDifficulties", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "Quizz_Question", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "QuestionTypes", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "Questions", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "QuestionAnswers", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "QuestionAnswer_Answer", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "Question_Answer", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "Pokemons", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "Pokemon_Weakness", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "Pokemon_TypePok", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "Pokemon_Talent", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "Pokemon_Attaque", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "Games", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "Difficulties", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "DataInfos", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "Attaques", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Guid", + table: "Answers", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Guid", + table: "TypesPok"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "TypeAttaques"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "Talents"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "Quizzs"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "QuizzDifficulties"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "Quizz_Question"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "QuestionTypes"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "Questions"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "QuestionAnswers"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "QuestionAnswer_Answer"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "Question_Answer"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "Pokemons"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "Pokemon_Weakness"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "Pokemon_TypePok"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "Pokemon_Talent"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "Pokemon_Attaque"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "Games"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "Difficulties"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "DataInfos"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "Attaques"); + + migrationBuilder.DropColumn( + name: "Guid", + table: "Answers"); + } + } +} diff --git a/WebApiScrapingData.Infrastructure/Migrations/ScrapingContextModelSnapshot.cs b/WebApiScrapingData.Infrastructure/Migrations/ScrapingContextModelSnapshot.cs index d4b5fc4..0e237cd 100644 --- a/WebApiScrapingData.Infrastructure/Migrations/ScrapingContextModelSnapshot.cs +++ b/WebApiScrapingData.Infrastructure/Migrations/ScrapingContextModelSnapshot.cs @@ -261,6 +261,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Description_RU") .HasColumnType("nvarchar(max)"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("Name_CN") .HasColumnType("nvarchar(max)"); @@ -353,6 +356,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Evolutions") .HasColumnType("nvarchar(max)"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("Name") .HasColumnType("nvarchar(max)"); @@ -405,6 +411,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateModification") .HasColumnType("datetime2"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("Name_CN") .HasColumnType("nvarchar(max)"); @@ -475,6 +484,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Generation") .HasColumnType("int"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("Id_CN") .HasColumnType("bigint"); @@ -601,6 +613,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateModification") .HasColumnType("datetime2"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("Level") .HasColumnType("nvarchar(max)"); @@ -642,6 +657,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateModification") .HasColumnType("datetime2"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("IsHidden") .HasColumnType("bit"); @@ -683,6 +701,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateModification") .HasColumnType("datetime2"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("PokemonId") .HasColumnType("bigint"); @@ -721,6 +742,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateModification") .HasColumnType("datetime2"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("PokemonId") .HasColumnType("bigint"); @@ -759,6 +783,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateModification") .HasColumnType("datetime2"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("IsCorrect") .HasColumnType("bit"); @@ -805,6 +832,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateModification") .HasColumnType("datetime2"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("Libelle_CN") .HasColumnType("nvarchar(max)"); @@ -866,6 +896,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Done") .HasColumnType("bit"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("Order") .HasColumnType("int"); @@ -905,6 +938,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateModification") .HasColumnType("datetime2"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("QuestionId") .HasColumnType("bigint"); @@ -940,6 +976,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateModification") .HasColumnType("datetime2"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("QuestionId") .HasColumnType("bigint"); @@ -981,6 +1020,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateModification") .HasColumnType("datetime2"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("QuestionAnswerId") .HasColumnType("bigint"); @@ -1022,6 +1064,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DifficultyId") .HasColumnType("bigint"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("IsBlurred") .HasColumnType("bit"); @@ -1109,6 +1154,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("GenArceus") .HasColumnType("bit"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("Hard") .HasColumnType("bit"); @@ -1148,6 +1196,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateModification") .HasColumnType("datetime2"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("QuestionId") .HasColumnType("bigint"); @@ -1189,6 +1240,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Easy") .HasColumnType("bit"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("Hard") .HasColumnType("bit"); @@ -1258,6 +1312,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Description_RU") .HasColumnType("nvarchar(max)"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("Name_CN") .HasColumnType("nvarchar(max)"); @@ -1340,6 +1397,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Description_RU") .HasColumnType("nvarchar(max)"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("Name_CN") .HasColumnType("nvarchar(max)"); @@ -1401,6 +1461,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateModification") .HasColumnType("datetime2"); + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + b.Property("ImgColor") .HasColumnType("nvarchar(max)"); diff --git a/WebApiScrapingData.Infrastructure/Repository/Class/AttaqueRepository.cs b/WebApiScrapingData.Infrastructure/Repository/Class/AttaqueRepository.cs index 9c7e7d7..81ea89c 100644 --- a/WebApiScrapingData.Infrastructure/Repository/Class/AttaqueRepository.cs +++ b/WebApiScrapingData.Infrastructure/Repository/Class/AttaqueRepository.cs @@ -23,6 +23,11 @@ public override async Task> Find(Expression m.TypeAttaque).Include(m => m.TypePok).SingleAsync(x => x.Id.Equals(id)); } + + public override async Task GetByGuid(Guid guid) + { + return await this._context.Attaques.Include(m => m.TypeAttaque).Include(m => m.TypePok).SingleAsync(x => x.Guid.Equals(guid)); + } public async Task GetByName(string name) { diff --git a/WebApiScrapingData.Infrastructure/Repository/Class/DataInfoRepository.cs b/WebApiScrapingData.Infrastructure/Repository/Class/DataInfoRepository.cs index 167fc48..d655beb 100644 --- a/WebApiScrapingData.Infrastructure/Repository/Class/DataInfoRepository.cs +++ b/WebApiScrapingData.Infrastructure/Repository/Class/DataInfoRepository.cs @@ -25,37 +25,17 @@ public async Task SaveJsonInDb(string json) } } - public Task SaveJsonInDb(DataInfoJson dataInfoJson) + public async Task SaveJsonInDb(DataInfoJson dataInfoJson) { DataInfo dataInfo = new(); MapToInstance(dataInfo, dataInfoJson); - return Task.FromResult(AddInPokemon(dataInfo)); + await Add(dataInfo); + return await Task.FromResult(dataInfo); } #endregion #endregion #region Private Methods - private DataInfo AddInPokemon(DataInfo entity) - { - UpdateInfo(entity); - return this._context.DataInfos.Add(entity).Entity; - } - - private void UpdateInfo(DataInfo dataInfo, bool edit = false) - { - dataInfo.UserModification = "System"; - dataInfo.DateModification = DateTime.Now; - - if (!edit) - { - dataInfo.UserCreation = "System"; - dataInfo.DateCreation = DateTime.Now; - dataInfo.versionModification = 1; - } - else - dataInfo.versionModification += 1; - } - public void MapToInstance(DataInfo dataInfo, DataInfoJson dataInfoJson) { dataInfo.Name = dataInfoJson.Name; diff --git a/WebApiScrapingData.Infrastructure/Repository/Class/PokemonRepository.cs b/WebApiScrapingData.Infrastructure/Repository/Class/PokemonRepository.cs index 564e113..1f663f2 100644 --- a/WebApiScrapingData.Infrastructure/Repository/Class/PokemonRepository.cs +++ b/WebApiScrapingData.Infrastructure/Repository/Class/PokemonRepository.cs @@ -94,9 +94,31 @@ public override async Task> Find(Expression m.Pokemon_Talents).ThenInclude(u => u.Talent) .Include(m => m.Pokemon_Attaques).ThenInclude(u => u.Attaque).ThenInclude(u => u.TypePok) .Include(m => m.Pokemon_Attaques).ThenInclude(u => u.Attaque).ThenInclude(u => u.TypeAttaque) + .Include(m => m.Game) .SingleAsync(x => x.Id.Equals(id)); } + public override async Task GetByGuid(Guid guid) + { + return await _context.Pokemons + .Include(m => m.FR) + .Include(m => m.EN) + .Include(m => m.ES) + .Include(m => m.IT) + .Include(m => m.DE) + .Include(m => m.RU) + .Include(m => m.CO) + .Include(m => m.CN) + .Include(m => m.JP) + .Include(m => m.Pokemon_TypePoks).ThenInclude(u => u.TypePok) + .Include(m => m.Pokemon_Weaknesses).ThenInclude(u => u.TypePok) + .Include(m => m.Pokemon_Talents).ThenInclude(u => u.Talent) + .Include(m => m.Pokemon_Attaques).ThenInclude(u => u.Attaque).ThenInclude(u => u.TypePok) + .Include(m => m.Pokemon_Attaques).ThenInclude(u => u.Attaque).ThenInclude(u => u.TypeAttaque) + .Include(m => m.Game) + .SingleAsync(x => x.Guid.Equals(guid)); + } + public override IQueryable Query() { return _context.Pokemons @@ -188,6 +210,7 @@ public async Task> GetAllVariantAsync(string number) .Include(m => m.Pokemon_Talents).ThenInclude(u => u.Talent) .Include(m => m.Pokemon_Attaques).ThenInclude(u => u.Attaque).ThenInclude(u => u.TypePok) .Include(m => m.Pokemon_Attaques).ThenInclude(u => u.Attaque).ThenInclude(u => u.TypeAttaque) + .Include(m => m.Game) .ToListAsync(); } #endregion @@ -590,21 +613,6 @@ private async Task MapToInstance(Pokemon pokemon, PokemonJson pokemonJson) pokemon.UrlImg = pokemonJson.UrlImg; pokemon.UrlSprite = pokemonJson.UrlSprite; } - - private void UpdateInfo(Pokemon entity, bool edit = false) - { - entity.UserModification = "System"; - entity.DateModification = DateTime.Now; - - if (!edit) - { - entity.UserCreation = "System"; - entity.DateCreation = DateTime.Now; - entity.versionModification = 1; - } - else - entity.versionModification += 1; - } #endregion } } diff --git a/WebApiScrapingData.Infrastructure/Repository/GenericClass/Repository.cs b/WebApiScrapingData.Infrastructure/Repository/GenericClass/Repository.cs index 9a4c94e..f0e39c4 100644 --- a/WebApiScrapingData.Infrastructure/Repository/GenericClass/Repository.cs +++ b/WebApiScrapingData.Infrastructure/Repository/GenericClass/Repository.cs @@ -1,5 +1,5 @@ using Microsoft.EntityFrameworkCore; -using System.Data.SqlTypes; +using System; using System.Linq.Expressions; using WebApiScrapingData.Core.Repositories; using WebApiScrapingData.Domain.Interface; @@ -28,6 +28,11 @@ public Repository(ScrapingContext context) return await _context.Set().SingleAsync(x => x.Id.Equals(id)); } + public virtual async Task GetByGuid(Guid guid) + { + return await _context.Set().SingleAsync(x => x.Guid.Equals(guid)); + } + public virtual IQueryable Query() { return _context.Set().AsQueryable(); @@ -113,7 +118,8 @@ private void UpdateInfo(T entity, bool edit = false) entity.DateModification = DateTime.Now; if (!edit) - { + { + entity.Guid = UpdateGuid(); entity.UserCreation = "System"; entity.DateCreation = DateTime.Now; entity.versionModification = 1; @@ -122,6 +128,22 @@ private void UpdateInfo(T entity, bool edit = false) entity.versionModification += 1; } + private Guid UpdateGuid() + { + bool guidOK = false; + Guid guid; + do + { + guid = Guid.NewGuid(); + Task obj = GetByGuid(guid); + if (obj.Result != null) + guidOK = true; + + } while (!guidOK); + + return guid; + } + private bool saveChanges() { // Enregistrez les modifications dans la base de données de manière synchrone diff --git a/WebApiScrapingData.Infrastructure/Settings/appSettings.json b/WebApiScrapingData.Infrastructure/Settings/appSettings.json index f87fa2d..6f0f230 100644 --- a/WebApiScrapingData.Infrastructure/Settings/appSettings.json +++ b/WebApiScrapingData.Infrastructure/Settings/appSettings.json @@ -7,6 +7,6 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "PokemonDataBase": "Server=192.168.1.14,1433;Database=Pokemon.DB.QuaTest;User Id=AdminUser;Password=Q5KZ/m2k#3i);" + "PokemonDataBase": "Server=192.168.1.14,1433;Database=Pokemon.DB.Qua;User Id=AdminUser;Password=Q5KZ/m2k#3i);" } } diff --git a/WepApiScrapingData/Controllers/Abstract/GenericController.cs b/WepApiScrapingData/Controllers/Abstract/GenericController.cs index 8faea91..9beb15f 100644 --- a/WepApiScrapingData/Controllers/Abstract/GenericController.cs +++ b/WepApiScrapingData/Controllers/Abstract/GenericController.cs @@ -78,6 +78,28 @@ public virtual async Task GetSingle(int id) return result; } + + [HttpGet] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + [Route("GetByGuid/{guid}")] + public virtual async Task GetByGuid(Guid guid) + { + IActionResult result = this.BadRequest(); + + try + { + result = this.Ok(await _repository.Find(m => m.Guid.Equals(guid))); + } + catch (Exception ex) + { + _logger.LogError(ex, ex.Message); + result = this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message); + } + + return result; + } #endregion #region Post diff --git a/WepApiScrapingData/Controllers/MigrationController.cs b/WepApiScrapingData/Controllers/MigrationController.cs new file mode 100644 index 0000000..c703b30 --- /dev/null +++ b/WepApiScrapingData/Controllers/MigrationController.cs @@ -0,0 +1,86 @@ +using Microsoft.AspNetCore.Cors; +using Microsoft.AspNetCore.Mvc; +using WebApiScrapingData.Domain.Class; +using WebApiScrapingData.Infrastructure.Data; +using WepApiScrapingData.ExtensionMethods; + +namespace WepApiScrapingData.Controllers +{ + + [ApiController] + [Route("api/v1.0/[controller]")] + [EnableCors(SecurityMethods.DEFAULT_POLICY)] + public class MigrationController : ControllerBase + { + #region Private fields + private readonly ILogger _logger; + private readonly ScrapingContext _context; + #endregion + + public MigrationController(ILogger logger, ScrapingContext context) + { + _logger = logger; + _context = context; + } + + [HttpPut] + [ProducesResponseType(StatusCodes.Status201Created)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + [Route("Migration-Add-Guid")] + public virtual IActionResult Update() + { + IActionResult result = this.BadRequest(); + + try + { + foreach (Pokemon item in _context.Pokemons) + item.Guid = Guid.NewGuid(); + + foreach (DataInfo item in _context.DataInfos) + item.Guid = Guid.NewGuid(); + + foreach (TypePok item in _context.TypesPok) + item.Guid = Guid.NewGuid(); + + foreach (Talent item in _context.Talents) + item.Guid = Guid.NewGuid(); + + foreach (Attaque item in _context.Attaques) + item.Guid = Guid.NewGuid(); + + foreach (TypeAttaque item in _context.TypeAttaques) + item.Guid = Guid.NewGuid(); + + foreach (Pokemon_TypePok item in _context.Pokemon_TypePok) + item.Guid = Guid.NewGuid(); + + foreach (Pokemon_Weakness item in _context.Pokemon_Weakness) + item.Guid = Guid.NewGuid(); + + foreach (Pokemon_Talent item in _context.Pokemon_Talent) + item.Guid = Guid.NewGuid(); + + foreach (Pokemon_Attaque item in _context.Pokemon_Attaque) + item.Guid = Guid.NewGuid(); + + foreach (Game item in _context.Games) + item.Guid = Guid.NewGuid(); + + var success = _context.SaveChanges(); + + if (success > 0) + { + result = this.Ok(); + } + + return result; + } + catch (Exception ex) + { + _logger.LogError(ex, ex.Message); + return this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message); + } + } + } +} diff --git a/WepApiScrapingData/appsettings.Development.json b/WepApiScrapingData/appsettings.Development.json index 620c8de..046fabc 100644 --- a/WepApiScrapingData/appsettings.Development.json +++ b/WepApiScrapingData/appsettings.Development.json @@ -7,7 +7,7 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "PokemonDataBase": "Server=192.168.1.14,1433;Database=Pokemon.DB.QuaTest;User Id=AdminUser;Password=Q5KZ/m2k#3i);" + "PokemonDataBase": "Server=192.168.1.14,1433;Database=Pokemon.DB.Qua;User Id=AdminUser;Password=Q5KZ/m2k#3i);" }, "Cors": { "Origin": "http://localhost:4200" diff --git a/WepApiScrapingData/appsettings.json b/WepApiScrapingData/appsettings.json index 620c8de..046fabc 100644 --- a/WepApiScrapingData/appsettings.json +++ b/WepApiScrapingData/appsettings.json @@ -7,7 +7,7 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "PokemonDataBase": "Server=192.168.1.14,1433;Database=Pokemon.DB.QuaTest;User Id=AdminUser;Password=Q5KZ/m2k#3i);" + "PokemonDataBase": "Server=192.168.1.14,1433;Database=Pokemon.DB.Qua;User Id=AdminUser;Password=Q5KZ/m2k#3i);" }, "Cors": { "Origin": "http://localhost:4200"