From 502eba2552aad3e6aa19f4473373835ecc29a3e1 Mon Sep 17 00:00:00 2001 From: Kevin MONDEJAR Date: Fri, 14 Mar 2025 12:23:17 +0100 Subject: [PATCH] J'y suis presque --- WF_EF_Api/Contextlib/WTFContext.cs | 17 +- WF_EF_Api/Entity/Favorite.cs | 4 + WF_EF_Api/Entity/Question.cs | 2 +- WF_EF_Api/Entity/Quote.cs | 6 + ...0250312160314_myFirstMigration.Designer.cs | 205 ---- .../20250312160314_myFirstMigration.cs | 149 --- .../20250312162514_migr2.Designer.cs | 248 ---- .../Migrations/20250312162514_migr2.cs | 89 -- .../20250314112216_migrationTest1.Designer.cs | 1071 +++++++++++++++++ .../20250314112216_migrationTest1.cs | 501 ++++++++ .../Migrations/StubWTFContextModelSnapshot.cs | 885 +++++++++++++- WF_EF_Api/StubbedContextLib/StubWTFContext.cs | 97 +- 12 files changed, 2500 insertions(+), 774 deletions(-) delete mode 100644 WF_EF_Api/StubbedContextLib/Migrations/20250312160314_myFirstMigration.Designer.cs delete mode 100644 WF_EF_Api/StubbedContextLib/Migrations/20250312160314_myFirstMigration.cs delete mode 100644 WF_EF_Api/StubbedContextLib/Migrations/20250312162514_migr2.Designer.cs delete mode 100644 WF_EF_Api/StubbedContextLib/Migrations/20250312162514_migr2.cs create mode 100644 WF_EF_Api/StubbedContextLib/Migrations/20250314112216_migrationTest1.Designer.cs create mode 100644 WF_EF_Api/StubbedContextLib/Migrations/20250314112216_migrationTest1.cs diff --git a/WF_EF_Api/Contextlib/WTFContext.cs b/WF_EF_Api/Contextlib/WTFContext.cs index ad5e4e5..f98290d 100644 --- a/WF_EF_Api/Contextlib/WTFContext.cs +++ b/WF_EF_Api/Contextlib/WTFContext.cs @@ -14,7 +14,7 @@ namespace Contextlib public DbSet characters { get; set; } public DbSet comments { get; set; } public DbSet dailyquotes { get; set; } - //public DbSet favorites { get; set; } + public DbSet favorites { get; set; } public DbSet images { get; set; } public DbSet question { get; set; } public DbSet quizzes { get; set; } @@ -32,10 +32,19 @@ namespace Contextlib .HasMany(q => q.Favorite) .WithMany(u => u.Favorite) .UsingEntity( - l => l.HasOne().WithMany().HasForeignKey(q => q.IdQuote), - r => r.HasOne().WithMany().HasForeignKey(u => u.IdUsers) + l => l.HasOne(f => f.Quote) + .WithMany() + .HasForeignKey(f => f.IdQuote), + r => r.HasOne(f => f.Users) + .WithMany() + .HasForeignKey(f => f.IdUsers) ); + modelBuilder.Entity() + .HasMany(u => u.Quotes) + .WithOne(q => q.User) + .HasForeignKey(q => q.IdUsersPropose); + modelBuilder.Entity() .HasMany(q => q.Questions) .WithMany(u => u.Quizs) @@ -46,6 +55,6 @@ namespace Contextlib } protected override void OnConfiguring(DbContextOptionsBuilder options) - => options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=WfDatabase.mdf;Trusted_Connection=True;"); + => options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Wf-Database.mdf;Trusted_Connection=True;"); } } diff --git a/WF_EF_Api/Entity/Favorite.cs b/WF_EF_Api/Entity/Favorite.cs index ec60347..06e1185 100644 --- a/WF_EF_Api/Entity/Favorite.cs +++ b/WF_EF_Api/Entity/Favorite.cs @@ -12,6 +12,10 @@ namespace Entity { public int IdUsers { get; set; } + public Users Users { get; set; } + public int IdQuote { get; set; } + + public Quote Quote { get; set; } } } diff --git a/WF_EF_Api/Entity/Question.cs b/WF_EF_Api/Entity/Question.cs index 036747d..b2e37e9 100644 --- a/WF_EF_Api/Entity/Question.cs +++ b/WF_EF_Api/Entity/Question.cs @@ -15,7 +15,7 @@ namespace Entity public int Id { get; set; } [Required] - [StringLength(50)] + [StringLength(200)] public string Text { get; set; } [Required] diff --git a/WF_EF_Api/Entity/Quote.cs b/WF_EF_Api/Entity/Quote.cs index e91cd13..976f62e 100644 --- a/WF_EF_Api/Entity/Quote.cs +++ b/WF_EF_Api/Entity/Quote.cs @@ -39,6 +39,12 @@ namespace Entity [ForeignKey(nameof(Users))] public int IdUsersPropose { get; set; } + public Users User { get; set; } = null!; + + public Source Source { get; set; } = null!; + + public Character Character { get; set; } = null!; + public ICollection DailyQuotes { get; set; } = new List(); public ICollection commentaries { get; set; } = new List(); diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250312160314_myFirstMigration.Designer.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250312160314_myFirstMigration.Designer.cs deleted file mode 100644 index 516d42a..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250312160314_myFirstMigration.Designer.cs +++ /dev/null @@ -1,205 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using StubbedContextLib; - -#nullable disable - -namespace StubbedContextLib.Migrations -{ - [DbContext(typeof(StubWTFContext))] - [Migration("20250312160314_myFirstMigration")] - partial class myFirstMigration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "9.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Entity.Character", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Character"); - }); - - modelBuilder.Entity("Entity.Images", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ImgPath") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Images"); - }); - - modelBuilder.Entity("Entity.Question", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AnswerA") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("AnswerB") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("AnswerC") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("AnswerD") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CorrectAnswer") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Text") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Question"); - }); - - modelBuilder.Entity("Entity.Quiz", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("NbQuestion") - .HasColumnType("int"); - - b.Property("Title") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Quiz"); - }); - - modelBuilder.Entity("Entity.Quote", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Content") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsValid") - .HasColumnType("bit"); - - b.Property("Langage") - .HasColumnType("int"); - - b.Property("Likes") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Quote"); - }); - - modelBuilder.Entity("Entity.Source", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Title") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Year") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Source"); - }); - - modelBuilder.Entity("Entity.Users", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - - b.HasData( - new - { - Id = 1, - Created = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "dev@gmail.com", - Password = "1234", - UserName = "Dev" - }); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250312160314_myFirstMigration.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250312160314_myFirstMigration.cs deleted file mode 100644 index 6fd3de5..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250312160314_myFirstMigration.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace StubbedContextLib.Migrations -{ - /// - public partial class myFirstMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Character", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Name = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Character", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Images", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ImgPath = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Images", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Question", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Text = table.Column(type: "nvarchar(max)", nullable: false), - AnswerA = table.Column(type: "nvarchar(max)", nullable: false), - AnswerB = table.Column(type: "nvarchar(max)", nullable: false), - AnswerC = table.Column(type: "nvarchar(max)", nullable: false), - AnswerD = table.Column(type: "nvarchar(max)", nullable: false), - CorrectAnswer = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Question", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Quiz", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Title = table.Column(type: "nvarchar(max)", nullable: false), - NbQuestion = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Quiz", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Quote", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Content = table.Column(type: "nvarchar(max)", nullable: false), - Likes = table.Column(type: "int", nullable: false), - Langage = table.Column(type: "int", nullable: false), - IsValid = table.Column(type: "bit", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Quote", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Source", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Title = table.Column(type: "nvarchar(max)", nullable: false), - Year = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Source", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - UserName = table.Column(type: "nvarchar(max)", nullable: false), - Email = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false), - Created = table.Column(type: "datetime2", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - }); - - migrationBuilder.InsertData( - table: "Users", - columns: new[] { "Id", "Created", "Email", "Password", "UserName" }, - values: new object[] { 1, new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "dev@gmail.com", "1234", "Dev" }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Character"); - - migrationBuilder.DropTable( - name: "Images"); - - migrationBuilder.DropTable( - name: "Question"); - - migrationBuilder.DropTable( - name: "Quiz"); - - migrationBuilder.DropTable( - name: "Quote"); - - migrationBuilder.DropTable( - name: "Source"); - - migrationBuilder.DropTable( - name: "Users"); - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250312162514_migr2.Designer.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250312162514_migr2.Designer.cs deleted file mode 100644 index d84e486..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250312162514_migr2.Designer.cs +++ /dev/null @@ -1,248 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using StubbedContextLib; - -#nullable disable - -namespace StubbedContextLib.Migrations -{ - [DbContext(typeof(StubWTFContext))] - [Migration("20250312162514_migr2")] - partial class migr2 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "9.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Entity.Character", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Character"); - }); - - modelBuilder.Entity("Entity.Images", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ImgPath") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Images"); - - b.HasData( - new - { - Id = 1, - ImgPath = "coucou" - }, - new - { - Id = 2, - ImgPath = "bonjour" - }); - }); - - modelBuilder.Entity("Entity.Question", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AnswerA") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("AnswerB") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("AnswerC") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("AnswerD") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CorrectAnswer") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Text") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Question"); - }); - - modelBuilder.Entity("Entity.Quiz", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("NbQuestion") - .HasColumnType("int"); - - b.Property("Title") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Quiz"); - }); - - modelBuilder.Entity("Entity.Quote", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Content") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsValid") - .HasColumnType("bit"); - - b.Property("Langage") - .HasColumnType("int"); - - b.Property("Likes") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Quote"); - }); - - modelBuilder.Entity("Entity.Source", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Title") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Year") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Source"); - }); - - modelBuilder.Entity("Entity.Users", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IdImage") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("IdImage"); - - b.ToTable("Users"); - - b.HasData( - new - { - Id = 1, - Created = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "dev@gmail.com", - IdImage = 1, - Password = "1234", - UserName = "Dev" - }, - new - { - Id = 2, - Created = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "admin@gmail.com", - IdImage = 1, - Password = "1234", - UserName = "Admin" - }); - }); - - modelBuilder.Entity("Entity.Users", b => - { - b.HasOne("Entity.Images", "Images") - .WithMany("Users") - .HasForeignKey("IdImage") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Images"); - }); - - modelBuilder.Entity("Entity.Images", b => - { - b.Navigation("Users"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250312162514_migr2.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250312162514_migr2.cs deleted file mode 100644 index 01e2609..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250312162514_migr2.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace StubbedContextLib.Migrations -{ - /// - public partial class migr2 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "IdImage", - table: "Users", - type: "int", - nullable: false, - defaultValue: 0); - - migrationBuilder.InsertData( - table: "Images", - columns: new[] { "Id", "ImgPath" }, - values: new object[,] - { - { 1, "coucou" }, - { 2, "bonjour" } - }); - - migrationBuilder.UpdateData( - table: "Users", - keyColumn: "Id", - keyValue: 1, - column: "IdImage", - value: 1); - - migrationBuilder.InsertData( - table: "Users", - columns: new[] { "Id", "Created", "Email", "IdImage", "Password", "UserName" }, - values: new object[] { 2, new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "admin@gmail.com", 1, "1234", "Admin" }); - - migrationBuilder.CreateIndex( - name: "IX_Users_IdImage", - table: "Users", - column: "IdImage"); - - migrationBuilder.AddForeignKey( - name: "FK_Users_Images_IdImage", - table: "Users", - column: "IdImage", - principalTable: "Images", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Users_Images_IdImage", - table: "Users"); - - migrationBuilder.DropIndex( - name: "IX_Users_IdImage", - table: "Users"); - - migrationBuilder.DeleteData( - table: "Images", - keyColumn: "Id", - keyValue: 2); - - migrationBuilder.DeleteData( - table: "Users", - keyColumn: "Id", - keyValue: 2); - - migrationBuilder.DeleteData( - table: "Images", - keyColumn: "Id", - keyValue: 1); - - migrationBuilder.DropColumn( - name: "IdImage", - table: "Users"); - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250314112216_migrationTest1.Designer.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250314112216_migrationTest1.Designer.cs new file mode 100644 index 0000000..d466b28 --- /dev/null +++ b/WF_EF_Api/StubbedContextLib/Migrations/20250314112216_migrationTest1.Designer.cs @@ -0,0 +1,1071 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using StubbedContextLib; + +#nullable disable + +namespace StubbedContextLib.Migrations +{ + [DbContext(typeof(StubWTFContext))] + [Migration("20250314112216_migrationTest1")] + partial class migrationTest1 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Entity.Character", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IdImage") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("IdImage"); + + b.ToTable("characters"); + + b.HasData( + new + { + Id = 1, + IdImage = 1, + Name = "Alan Grant" + }, + new + { + Id = 2, + IdImage = 2, + Name = "Aragorn" + }, + new + { + Id = 3, + IdImage = 3, + Name = "Legolas" + }, + new + { + Id = 4, + IdImage = 4, + Name = "Frodon" + }, + new + { + Id = 5, + IdImage = 5, + Name = "Dobby" + }, + new + { + Id = 6, + IdImage = 6, + Name = "Jon Snow" + }, + new + { + Id = 7, + IdImage = 7, + Name = "Daenerys Targaryen" + }, + new + { + Id = 8, + IdImage = 8, + Name = "Luke Skywalker" + }, + new + { + Id = 9, + IdImage = 9, + Name = "Princess Leia" + }, + new + { + Id = 10, + IdImage = 10, + Name = "Harry Potter" + }); + }); + + modelBuilder.Entity("Entity.Commentary", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Comment") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("DateCommentary") + .HasColumnType("date") + .HasColumnName("DateCommentary"); + + b.Property("IdQuote") + .HasColumnType("int"); + + b.Property("IdUsers") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IdQuote"); + + b.HasIndex("IdUsers"); + + b.ToTable("comments"); + + b.HasData( + new + { + Id = 1, + Comment = "Ce film est le meilleur", + DateCommentary = new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), + IdQuote = 1, + IdUsers = 2 + }, + new + { + Id = 2, + Comment = "Very good", + DateCommentary = new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), + IdQuote = 1, + IdUsers = 3 + }); + }); + + modelBuilder.Entity("Entity.DailyQuote", b => + { + b.Property("IdQuote") + .HasColumnType("int"); + + b.HasKey("IdQuote"); + + b.ToTable("dailyquotes"); + + b.HasData( + new + { + IdQuote = 1 + }, + new + { + IdQuote = 5 + }); + }); + + modelBuilder.Entity("Entity.Favorite", b => + { + b.Property("IdQuote") + .HasColumnType("int"); + + b.Property("IdUsers") + .HasColumnType("int"); + + b.HasKey("IdQuote", "IdUsers"); + + b.HasIndex("IdUsers"); + + b.ToTable("favorites"); + + b.HasData( + new + { + IdQuote = 2, + IdUsers = 8 + }, + new + { + IdQuote = 5, + IdUsers = 3 + }, + new + { + IdQuote = 9, + IdUsers = 1 + }, + new + { + IdQuote = 4, + IdUsers = 10 + }, + new + { + IdQuote = 3, + IdUsers = 2 + }, + new + { + IdQuote = 6, + IdUsers = 7 + }, + new + { + IdQuote = 1, + IdUsers = 6 + }, + new + { + IdQuote = 8, + IdUsers = 9 + }, + new + { + IdQuote = 10, + IdUsers = 5 + }); + }); + + modelBuilder.Entity("Entity.Images", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImgPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("images"); + + b.HasData( + new + { + Id = 1, + ImgPath = "https://th.bing.com/th/id/OIP.TJuWNCsibz8MVmhdNQEdMwHaE8?w=244&h=180&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 2, + ImgPath = "https://th.bing.com/th/id/OIP.NgXRQ5-IknA6_qOPFhLWIwHaHK?w=165&h=180&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 3, + ImgPath = "https://th.bing.com/th/id/OIP.XcJoJ6bC9sAMjol1pJn5UQHaLH?w=118&h=180&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 4, + ImgPath = "https://th.bing.com/th/id/OIP.PPIESqZaNDa-qUcfSDXhdQHaGK?w=210&h=180&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 5, + ImgPath = "https://th.bing.com/th/id/OIP.XBghSl2kfRNNtQoSxc901wHaHa?w=177&h=180&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 6, + ImgPath = "https://th.bing.com/th/id/OIP.af1Aid64cqEKoIOBgCPxtQHaJO?w=145&h=182&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 7, + ImgPath = "https://th.bing.com/th/id/OIP.ri5vSXr5lNTLt4DO6KQXyQHaI4?w=158&h=189&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 8, + ImgPath = "https://th.bing.com/th/id/OIP.uPTRLR8uspCiafiunUqKfQHaMJ?w=115&h=180&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 9, + ImgPath = "https://th.bing.com/th/id/OIP.hcJis4rKbyQtugsoFJU2ngHaM_?w=118&h=207&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 10, + ImgPath = "https://th.bing.com/th/id/OIP.Py1_XfUrKJY_A6tYEmFS5wHaE8?w=280&h=187&c=7&r=0&o=5&pid=1.7" + }); + }); + + modelBuilder.Entity("Entity.Question", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AnswerA") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("AnswerB") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("AnswerC") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("AnswerD") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CorrectAnswer") + .IsRequired() + .HasMaxLength(1) + .HasColumnType("nvarchar(1)"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.ToTable("question"); + + b.HasData( + new + { + Id = 1, + AnswerA = "Gimli", + AnswerB = "Aragorn", + AnswerC = "Frodon", + AnswerD = "Gandalf", + CorrectAnswer = "B", + Text = "Qui est le leader de la Communauté de l'Anneau ?" + }, + new + { + Id = 2, + AnswerA = "Serdaigle", + AnswerB = "Gryffondor", + AnswerC = "Serpentard", + AnswerD = "Poufsouffle", + CorrectAnswer = "B", + Text = "Dans quelle maison Harry Potter est-il ?" + }, + new + { + Id = 3, + AnswerA = "Saroumane", + AnswerB = "Sauron", + AnswerC = "Gollum", + AnswerD = "Gothmog", + CorrectAnswer = "B", + Text = "Qui est le Seigneur des Ténèbres dans la saga Le Seigneur des Anneaux ?" + }, + new + { + Id = 4, + AnswerA = "Han Solo", + AnswerB = "Princesse Leia", + AnswerC = "Chewbacca", + AnswerD = "R2-D2", + CorrectAnswer = "A", + Text = "Dans le film Star Wars : Episode IV, qui sauve Luke Skywalker de l'Étoile de la Mort ?" + }, + new + { + Id = 5, + AnswerA = "Reine Jadis", + AnswerB = "Aslan", + AnswerC = "Edmund", + AnswerD = "Lucy", + CorrectAnswer = "B", + Text = "Qui est le souverain de Narnia dans Le Lion, la Sorcière Blanche et l'Armoire Magique ?" + }, + new + { + Id = 6, + AnswerA = "Smaug", + AnswerB = "Falkor", + AnswerC = "Norbert", + AnswerD = "Shenron", + CorrectAnswer = "A", + Text = "Quel est le nom du dragon dans Le Hobbit ?" + }, + new + { + Id = 7, + AnswerA = "Bella Swan", + AnswerB = "Edward Cullen", + AnswerC = "Jacob Black", + AnswerD = "Victoria", + CorrectAnswer = "A", + Text = "Qui est la première personne à être mordue par un vampire dans Twilight ?" + }, + new + { + Id = 8, + AnswerA = "Obi-Wan Kenobi", + AnswerB = "Yoda", + AnswerC = "Han Solo", + AnswerD = "Luke Skywalker", + CorrectAnswer = "A", + Text = "Quel personnage dit Que la Force soit avec toi dans Star Wars ?" + }, + new + { + Id = 9, + AnswerA = "Dr. Ellie Sattler", + AnswerB = "Alan Grant", + AnswerC = "John Hammond", + AnswerD = "Dennis Nedry", + CorrectAnswer = "B", + Text = "Dans Jurassic Park, quel est le nom du paléontologue sur l'île ?" + }, + new + { + Id = 10, + AnswerA = "Cersei Lannister", + AnswerB = "Arya Stark", + AnswerC = "Daenerys Targaryen", + AnswerD = "Sansa Stark", + CorrectAnswer = "C", + Text = "Dans Game of Thrones, qui est surnommée la Mère des Dragons ?" + }); + }); + + modelBuilder.Entity("Entity.Quiz", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IdImage") + .HasColumnType("int"); + + b.Property("NbQuestion") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("IdImage"); + + b.ToTable("quizzes"); + + b.HasData( + new + { + Id = 1, + IdImage = 1, + NbQuestion = 5, + Title = "Quiz 1" + }, + new + { + Id = 2, + IdImage = 2, + NbQuestion = 5, + Title = "Quiz 2" + }); + }); + + modelBuilder.Entity("Entity.QuizQuestion", b => + { + b.Property("IdQuestion") + .HasColumnType("int"); + + b.Property("IdQuiz") + .HasColumnType("int"); + + b.HasKey("IdQuestion", "IdQuiz"); + + b.HasIndex("IdQuiz"); + + b.ToTable("QuizQuestion"); + + b.HasData( + new + { + IdQuestion = 1, + IdQuiz = 1 + }, + new + { + IdQuestion = 2, + IdQuiz = 1 + }, + new + { + IdQuestion = 3, + IdQuiz = 1 + }, + new + { + IdQuestion = 4, + IdQuiz = 1 + }, + new + { + IdQuestion = 5, + IdQuiz = 1 + }, + new + { + IdQuestion = 6, + IdQuiz = 2 + }, + new + { + IdQuestion = 7, + IdQuiz = 2 + }, + new + { + IdQuestion = 8, + IdQuiz = 2 + }, + new + { + IdQuestion = 9, + IdQuiz = 2 + }, + new + { + IdQuestion = 10, + IdQuiz = 2 + }); + }); + + modelBuilder.Entity("Entity.Quote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Content") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IdCharacter") + .HasColumnType("int"); + + b.Property("IdSource") + .HasColumnType("int"); + + b.Property("IdUsersPropose") + .HasColumnType("int"); + + b.Property("IsValid") + .HasColumnType("bit"); + + b.Property("Langage") + .HasColumnType("int"); + + b.Property("Likes") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IdCharacter"); + + b.HasIndex("IdSource"); + + b.HasIndex("IdUsersPropose"); + + b.ToTable("quotes"); + + b.HasData( + new + { + Id = 1, + Content = "Je n'y crois pas. Je n'y crois pas. Ce n'est pas possible", + IdCharacter = 1, + IdSource = 1, + IdUsersPropose = 1, + IsValid = true, + Langage = 1, + Likes = 11025 + }, + new + { + Id = 2, + Content = "There is always hope", + IdCharacter = 2, + IdSource = 2, + IdUsersPropose = 1, + IsValid = true, + Langage = 0, + Likes = 11025 + }, + new + { + Id = 3, + Content = "A red sun rises. Blood has been spilled this night.", + IdCharacter = 3, + IdSource = 2, + IdUsersPropose = 1, + IsValid = true, + Langage = 0, + Likes = 11025 + }, + new + { + Id = 4, + Content = "I wish the Ring had never come to me.I wish none of this had happened.", + IdCharacter = 4, + IdSource = 2, + IdUsersPropose = 1, + IsValid = true, + Langage = 0, + Likes = 11025 + }, + new + { + Id = 5, + Content = "Dobby is a free elf!", + IdCharacter = 5, + IdSource = 4, + IdUsersPropose = 1, + IsValid = true, + Langage = 0, + Likes = 11025 + }, + new + { + Id = 6, + Content = "Winter is comming", + IdCharacter = 6, + IdSource = 3, + IdUsersPropose = 1, + IsValid = true, + Langage = 0, + Likes = 11025 + }, + new + { + Id = 7, + Content = "Je suis la dernière Targaryen. Je suis la reine des dragons", + IdCharacter = 7, + IdSource = 3, + IdUsersPropose = 1, + IsValid = true, + Langage = 1, + Likes = 11025 + }, + new + { + Id = 8, + Content = "Je ne suis pas prêt à affronter ça. C'est trop pour moi.", + IdCharacter = 8, + IdSource = 5, + IdUsersPropose = 1, + IsValid = true, + Langage = 1, + Likes = 11025 + }, + new + { + Id = 9, + Content = "Aidez-moi, Obi-Wan Kenobi, vous êtes mon seul espoir.", + IdCharacter = 9, + IdSource = 5, + IdUsersPropose = 1, + IsValid = true, + Langage = 1, + Likes = 11025 + }, + new + { + Id = 10, + Content = "La quoi ?", + IdCharacter = 10, + IdSource = 4, + IdUsersPropose = 1, + IsValid = true, + Langage = 1, + Likes = 11025 + }); + }); + + modelBuilder.Entity("Entity.Source", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TypeSrc") + .HasColumnType("int"); + + b.Property("Year") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("sources"); + + b.HasData( + new + { + Id = 1, + Title = "Jurassic Park", + TypeSrc = 0, + Year = 1993 + }, + new + { + Id = 2, + Title = "Le Seigneur des anneaux : La Communauté de l'anneau", + TypeSrc = 0, + Year = 2001 + }, + new + { + Id = 3, + Title = "Game of throne", + TypeSrc = 1, + Year = 2011 + }, + new + { + Id = 4, + Title = "Harry Potter à l'école des sorcier", + TypeSrc = 0, + Year = 1997 + }, + new + { + Id = 5, + Title = "Star Wars, épisode IV : Un nouvel espoir", + TypeSrc = 0, + Year = 1977 + }); + }); + + modelBuilder.Entity("Entity.Users", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("date") + .HasColumnName("Created"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IdImage") + .HasColumnType("int"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UserName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("IdImage"); + + b.ToTable("users"); + + b.HasData( + new + { + Id = 1, + Created = new DateTime(2025, 5, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "jhonDhoe@gmail.com", + IdImage = 1, + Password = "1234", + UserName = "Jhon-Dhoe" + }, + new + { + Id = 2, + Created = new DateTime(2025, 3, 19, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "lucy_rose@outlook.com", + IdImage = 2, + Password = "abcd", + UserName = "Lucy-Rose" + }, + new + { + Id = 3, + Created = new DateTime(2024, 11, 2, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "mark.taylor@yahoo.com", + IdImage = 3, + Password = "5678", + UserName = "Mark-Taylor" + }, + new + { + Id = 4, + Created = new DateTime(2025, 2, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "sophie.martin@gmail.com", + IdImage = 4, + Password = "4321", + UserName = "Sophie-Martin" + }, + new + { + Id = 5, + Created = new DateTime(2025, 1, 15, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "nathan_doe@aol.com", + IdImage = 5, + Password = "8765", + UserName = "Nathan-Doe" + }, + new + { + Id = 6, + Created = new DateTime(2025, 4, 7, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "ella.brown@icloud.com", + IdImage = 6, + Password = "2468", + UserName = "Ella-Brown" + }, + new + { + Id = 7, + Created = new DateTime(2024, 12, 25, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "oliver_smith@gmail.com", + IdImage = 7, + Password = "1357", + UserName = "Oliver-Smith" + }, + new + { + Id = 8, + Created = new DateTime(2025, 3, 5, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "mia.jones@outlook.com", + IdImage = 8, + Password = "1122", + UserName = "Mia-Jones" + }, + new + { + Id = 9, + Created = new DateTime(2025, 2, 22, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "kevin_williams@aol.com", + IdImage = 9, + Password = "2233", + UserName = "Kevin-Williams" + }, + new + { + Id = 10, + Created = new DateTime(2025, 1, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "olivia.white@yahoo.com", + IdImage = 10, + Password = "3344", + UserName = "Olivia-White" + }); + }); + + modelBuilder.Entity("Entity.Character", b => + { + b.HasOne("Entity.Images", "Images") + .WithMany("Characters") + .HasForeignKey("IdImage") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Images"); + }); + + modelBuilder.Entity("Entity.Commentary", b => + { + b.HasOne("Entity.Quote", "Quote") + .WithMany("commentaries") + .HasForeignKey("IdQuote") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entity.Users", "Users") + .WithMany("Commentary") + .HasForeignKey("IdUsers") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Quote"); + + b.Navigation("Users"); + }); + + modelBuilder.Entity("Entity.DailyQuote", b => + { + b.HasOne("Entity.Quote", "Quote") + .WithMany("DailyQuotes") + .HasForeignKey("IdQuote") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Quote"); + }); + + modelBuilder.Entity("Entity.Favorite", b => + { + b.HasOne("Entity.Quote", "Quote") + .WithMany() + .HasForeignKey("IdQuote") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entity.Users", "Users") + .WithMany() + .HasForeignKey("IdUsers") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Quote"); + + b.Navigation("Users"); + }); + + modelBuilder.Entity("Entity.Quiz", b => + { + b.HasOne("Entity.Images", "Images") + .WithMany("Quizs") + .HasForeignKey("IdImage") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Images"); + }); + + modelBuilder.Entity("Entity.QuizQuestion", b => + { + b.HasOne("Entity.Question", null) + .WithMany() + .HasForeignKey("IdQuestion") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entity.Quiz", null) + .WithMany() + .HasForeignKey("IdQuiz") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entity.Quote", b => + { + b.HasOne("Entity.Character", "Character") + .WithMany("Quotes") + .HasForeignKey("IdCharacter") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entity.Source", "Source") + .WithMany("Quotes") + .HasForeignKey("IdSource") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entity.Users", "User") + .WithMany("Quotes") + .HasForeignKey("IdUsersPropose") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Character"); + + b.Navigation("Source"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Entity.Users", b => + { + b.HasOne("Entity.Images", "Images") + .WithMany("Users") + .HasForeignKey("IdImage") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Images"); + }); + + modelBuilder.Entity("Entity.Character", b => + { + b.Navigation("Quotes"); + }); + + modelBuilder.Entity("Entity.Images", b => + { + b.Navigation("Characters"); + + b.Navigation("Quizs"); + + b.Navigation("Users"); + }); + + modelBuilder.Entity("Entity.Quote", b => + { + b.Navigation("DailyQuotes"); + + b.Navigation("commentaries"); + }); + + modelBuilder.Entity("Entity.Source", b => + { + b.Navigation("Quotes"); + }); + + modelBuilder.Entity("Entity.Users", b => + { + b.Navigation("Commentary"); + + b.Navigation("Quotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250314112216_migrationTest1.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250314112216_migrationTest1.cs new file mode 100644 index 0000000..a85f30b --- /dev/null +++ b/WF_EF_Api/StubbedContextLib/Migrations/20250314112216_migrationTest1.cs @@ -0,0 +1,501 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace StubbedContextLib.Migrations +{ + /// + public partial class migrationTest1 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "images", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ImgPath = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_images", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "question", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Text = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + AnswerA = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + AnswerB = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + AnswerC = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + AnswerD = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + CorrectAnswer = table.Column(type: "nvarchar(1)", maxLength: 1, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_question", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "sources", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Title = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Year = table.Column(type: "int", nullable: false), + TypeSrc = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_sources", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "characters", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + IdImage = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_characters", x => x.Id); + table.ForeignKey( + name: "FK_characters_images_IdImage", + column: x => x.IdImage, + principalTable: "images", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "quizzes", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Title = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + IdImage = table.Column(type: "int", nullable: false), + NbQuestion = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_quizzes", x => x.Id); + table.ForeignKey( + name: "FK_quizzes_images_IdImage", + column: x => x.IdImage, + principalTable: "images", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "users", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Email = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Password = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + IdImage = table.Column(type: "int", nullable: false), + Created = table.Column(type: "date", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_users", x => x.Id); + table.ForeignKey( + name: "FK_users_images_IdImage", + column: x => x.IdImage, + principalTable: "images", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "QuizQuestion", + columns: table => new + { + IdQuiz = table.Column(type: "int", nullable: false), + IdQuestion = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_QuizQuestion", x => new { x.IdQuestion, x.IdQuiz }); + table.ForeignKey( + name: "FK_QuizQuestion_question_IdQuestion", + column: x => x.IdQuestion, + principalTable: "question", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_QuizQuestion_quizzes_IdQuiz", + column: x => x.IdQuiz, + principalTable: "quizzes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "quotes", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Content = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Likes = table.Column(type: "int", nullable: false), + Langage = table.Column(type: "int", nullable: false), + IsValid = table.Column(type: "bit", nullable: false), + IdCharacter = table.Column(type: "int", nullable: false), + IdSource = table.Column(type: "int", nullable: false), + IdUsersPropose = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_quotes", x => x.Id); + table.ForeignKey( + name: "FK_quotes_characters_IdCharacter", + column: x => x.IdCharacter, + principalTable: "characters", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_quotes_sources_IdSource", + column: x => x.IdSource, + principalTable: "sources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_quotes_users_IdUsersPropose", + column: x => x.IdUsersPropose, + principalTable: "users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "comments", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + IdUsers = table.Column(type: "int", nullable: false), + IdQuote = table.Column(type: "int", nullable: false), + DateCommentary = table.Column(type: "date", nullable: false), + Comment = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_comments", x => x.Id); + table.ForeignKey( + name: "FK_comments_quotes_IdQuote", + column: x => x.IdQuote, + principalTable: "quotes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_comments_users_IdUsers", + column: x => x.IdUsers, + principalTable: "users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "dailyquotes", + columns: table => new + { + IdQuote = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_dailyquotes", x => x.IdQuote); + table.ForeignKey( + name: "FK_dailyquotes_quotes_IdQuote", + column: x => x.IdQuote, + principalTable: "quotes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "favorites", + columns: table => new + { + IdUsers = table.Column(type: "int", nullable: false), + IdQuote = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_favorites", x => new { x.IdQuote, x.IdUsers }); + table.ForeignKey( + name: "FK_favorites_quotes_IdQuote", + column: x => x.IdQuote, + principalTable: "quotes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_favorites_users_IdUsers", + column: x => x.IdUsers, + principalTable: "users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.InsertData( + table: "images", + columns: new[] { "Id", "ImgPath" }, + values: new object[,] + { + { 1, "https://th.bing.com/th/id/OIP.TJuWNCsibz8MVmhdNQEdMwHaE8?w=244&h=180&c=7&r=0&o=5&pid=1.7" }, + { 2, "https://th.bing.com/th/id/OIP.NgXRQ5-IknA6_qOPFhLWIwHaHK?w=165&h=180&c=7&r=0&o=5&pid=1.7" }, + { 3, "https://th.bing.com/th/id/OIP.XcJoJ6bC9sAMjol1pJn5UQHaLH?w=118&h=180&c=7&r=0&o=5&pid=1.7" }, + { 4, "https://th.bing.com/th/id/OIP.PPIESqZaNDa-qUcfSDXhdQHaGK?w=210&h=180&c=7&r=0&o=5&pid=1.7" }, + { 5, "https://th.bing.com/th/id/OIP.XBghSl2kfRNNtQoSxc901wHaHa?w=177&h=180&c=7&r=0&o=5&pid=1.7" }, + { 6, "https://th.bing.com/th/id/OIP.af1Aid64cqEKoIOBgCPxtQHaJO?w=145&h=182&c=7&r=0&o=5&pid=1.7" }, + { 7, "https://th.bing.com/th/id/OIP.ri5vSXr5lNTLt4DO6KQXyQHaI4?w=158&h=189&c=7&r=0&o=5&pid=1.7" }, + { 8, "https://th.bing.com/th/id/OIP.uPTRLR8uspCiafiunUqKfQHaMJ?w=115&h=180&c=7&r=0&o=5&pid=1.7" }, + { 9, "https://th.bing.com/th/id/OIP.hcJis4rKbyQtugsoFJU2ngHaM_?w=118&h=207&c=7&r=0&o=5&pid=1.7" }, + { 10, "https://th.bing.com/th/id/OIP.Py1_XfUrKJY_A6tYEmFS5wHaE8?w=280&h=187&c=7&r=0&o=5&pid=1.7" } + }); + + migrationBuilder.InsertData( + table: "question", + columns: new[] { "Id", "AnswerA", "AnswerB", "AnswerC", "AnswerD", "CorrectAnswer", "Text" }, + values: new object[,] + { + { 1, "Gimli", "Aragorn", "Frodon", "Gandalf", "B", "Qui est le leader de la Communauté de l'Anneau ?" }, + { 2, "Serdaigle", "Gryffondor", "Serpentard", "Poufsouffle", "B", "Dans quelle maison Harry Potter est-il ?" }, + { 3, "Saroumane", "Sauron", "Gollum", "Gothmog", "B", "Qui est le Seigneur des Ténèbres dans la saga Le Seigneur des Anneaux ?" }, + { 4, "Han Solo", "Princesse Leia", "Chewbacca", "R2-D2", "A", "Dans le film Star Wars : Episode IV, qui sauve Luke Skywalker de l'Étoile de la Mort ?" }, + { 5, "Reine Jadis", "Aslan", "Edmund", "Lucy", "B", "Qui est le souverain de Narnia dans Le Lion, la Sorcière Blanche et l'Armoire Magique ?" }, + { 6, "Smaug", "Falkor", "Norbert", "Shenron", "A", "Quel est le nom du dragon dans Le Hobbit ?" }, + { 7, "Bella Swan", "Edward Cullen", "Jacob Black", "Victoria", "A", "Qui est la première personne à être mordue par un vampire dans Twilight ?" }, + { 8, "Obi-Wan Kenobi", "Yoda", "Han Solo", "Luke Skywalker", "A", "Quel personnage dit Que la Force soit avec toi dans Star Wars ?" }, + { 9, "Dr. Ellie Sattler", "Alan Grant", "John Hammond", "Dennis Nedry", "B", "Dans Jurassic Park, quel est le nom du paléontologue sur l'île ?" }, + { 10, "Cersei Lannister", "Arya Stark", "Daenerys Targaryen", "Sansa Stark", "C", "Dans Game of Thrones, qui est surnommée la Mère des Dragons ?" } + }); + + migrationBuilder.InsertData( + table: "sources", + columns: new[] { "Id", "Title", "TypeSrc", "Year" }, + values: new object[,] + { + { 1, "Jurassic Park", 0, 1993 }, + { 2, "Le Seigneur des anneaux : La Communauté de l'anneau", 0, 2001 }, + { 3, "Game of throne", 1, 2011 }, + { 4, "Harry Potter à l'école des sorcier", 0, 1997 }, + { 5, "Star Wars, épisode IV : Un nouvel espoir", 0, 1977 } + }); + + migrationBuilder.InsertData( + table: "characters", + columns: new[] { "Id", "IdImage", "Name" }, + values: new object[,] + { + { 1, 1, "Alan Grant" }, + { 2, 2, "Aragorn" }, + { 3, 3, "Legolas" }, + { 4, 4, "Frodon" }, + { 5, 5, "Dobby" }, + { 6, 6, "Jon Snow" }, + { 7, 7, "Daenerys Targaryen" }, + { 8, 8, "Luke Skywalker" }, + { 9, 9, "Princess Leia" }, + { 10, 10, "Harry Potter" } + }); + + migrationBuilder.InsertData( + table: "quizzes", + columns: new[] { "Id", "IdImage", "NbQuestion", "Title" }, + values: new object[,] + { + { 1, 1, 5, "Quiz 1" }, + { 2, 2, 5, "Quiz 2" } + }); + + migrationBuilder.InsertData( + table: "users", + columns: new[] { "Id", "Created", "Email", "IdImage", "Password", "UserName" }, + values: new object[,] + { + { 1, new DateTime(2025, 5, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), "jhonDhoe@gmail.com", 1, "1234", "Jhon-Dhoe" }, + { 2, new DateTime(2025, 3, 19, 0, 0, 0, 0, DateTimeKind.Unspecified), "lucy_rose@outlook.com", 2, "abcd", "Lucy-Rose" }, + { 3, new DateTime(2024, 11, 2, 0, 0, 0, 0, DateTimeKind.Unspecified), "mark.taylor@yahoo.com", 3, "5678", "Mark-Taylor" }, + { 4, new DateTime(2025, 2, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), "sophie.martin@gmail.com", 4, "4321", "Sophie-Martin" }, + { 5, new DateTime(2025, 1, 15, 0, 0, 0, 0, DateTimeKind.Unspecified), "nathan_doe@aol.com", 5, "8765", "Nathan-Doe" }, + { 6, new DateTime(2025, 4, 7, 0, 0, 0, 0, DateTimeKind.Unspecified), "ella.brown@icloud.com", 6, "2468", "Ella-Brown" }, + { 7, new DateTime(2024, 12, 25, 0, 0, 0, 0, DateTimeKind.Unspecified), "oliver_smith@gmail.com", 7, "1357", "Oliver-Smith" }, + { 8, new DateTime(2025, 3, 5, 0, 0, 0, 0, DateTimeKind.Unspecified), "mia.jones@outlook.com", 8, "1122", "Mia-Jones" }, + { 9, new DateTime(2025, 2, 22, 0, 0, 0, 0, DateTimeKind.Unspecified), "kevin_williams@aol.com", 9, "2233", "Kevin-Williams" }, + { 10, new DateTime(2025, 1, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), "olivia.white@yahoo.com", 10, "3344", "Olivia-White" } + }); + + migrationBuilder.InsertData( + table: "QuizQuestion", + columns: new[] { "IdQuestion", "IdQuiz" }, + values: new object[,] + { + { 1, 1 }, + { 2, 1 }, + { 3, 1 }, + { 4, 1 }, + { 5, 1 }, + { 6, 2 }, + { 7, 2 }, + { 8, 2 }, + { 9, 2 }, + { 10, 2 } + }); + + migrationBuilder.InsertData( + table: "quotes", + columns: new[] { "Id", "Content", "IdCharacter", "IdSource", "IdUsersPropose", "IsValid", "Langage", "Likes" }, + values: new object[,] + { + { 1, "Je n'y crois pas. Je n'y crois pas. Ce n'est pas possible", 1, 1, 1, true, 1, 11025 }, + { 2, "There is always hope", 2, 2, 1, true, 0, 11025 }, + { 3, "A red sun rises. Blood has been spilled this night.", 3, 2, 1, true, 0, 11025 }, + { 4, "I wish the Ring had never come to me.I wish none of this had happened.", 4, 2, 1, true, 0, 11025 }, + { 5, "Dobby is a free elf!", 5, 4, 1, true, 0, 11025 }, + { 6, "Winter is comming", 6, 3, 1, true, 0, 11025 }, + { 7, "Je suis la dernière Targaryen. Je suis la reine des dragons", 7, 3, 1, true, 1, 11025 }, + { 8, "Je ne suis pas prêt à affronter ça. C'est trop pour moi.", 8, 5, 1, true, 1, 11025 }, + { 9, "Aidez-moi, Obi-Wan Kenobi, vous êtes mon seul espoir.", 9, 5, 1, true, 1, 11025 }, + { 10, "La quoi ?", 10, 4, 1, true, 1, 11025 } + }); + + migrationBuilder.InsertData( + table: "comments", + columns: new[] { "Id", "Comment", "DateCommentary", "IdQuote", "IdUsers" }, + values: new object[,] + { + { 1, "Ce film est le meilleur", new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, 2 }, + { 2, "Very good", new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, 3 } + }); + + migrationBuilder.InsertData( + table: "dailyquotes", + column: "IdQuote", + values: new object[] + { + 1, + 5 + }); + + migrationBuilder.InsertData( + table: "favorites", + columns: new[] { "IdQuote", "IdUsers" }, + values: new object[,] + { + { 1, 6 }, + { 2, 8 }, + { 3, 2 }, + { 4, 10 }, + { 5, 3 }, + { 6, 7 }, + { 8, 9 }, + { 9, 1 }, + { 10, 5 } + }); + + migrationBuilder.CreateIndex( + name: "IX_characters_IdImage", + table: "characters", + column: "IdImage"); + + migrationBuilder.CreateIndex( + name: "IX_comments_IdQuote", + table: "comments", + column: "IdQuote"); + + migrationBuilder.CreateIndex( + name: "IX_comments_IdUsers", + table: "comments", + column: "IdUsers"); + + migrationBuilder.CreateIndex( + name: "IX_favorites_IdUsers", + table: "favorites", + column: "IdUsers"); + + migrationBuilder.CreateIndex( + name: "IX_QuizQuestion_IdQuiz", + table: "QuizQuestion", + column: "IdQuiz"); + + migrationBuilder.CreateIndex( + name: "IX_quizzes_IdImage", + table: "quizzes", + column: "IdImage"); + + migrationBuilder.CreateIndex( + name: "IX_quotes_IdCharacter", + table: "quotes", + column: "IdCharacter"); + + migrationBuilder.CreateIndex( + name: "IX_quotes_IdSource", + table: "quotes", + column: "IdSource"); + + migrationBuilder.CreateIndex( + name: "IX_quotes_IdUsersPropose", + table: "quotes", + column: "IdUsersPropose"); + + migrationBuilder.CreateIndex( + name: "IX_users_IdImage", + table: "users", + column: "IdImage"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "comments"); + + migrationBuilder.DropTable( + name: "dailyquotes"); + + migrationBuilder.DropTable( + name: "favorites"); + + migrationBuilder.DropTable( + name: "QuizQuestion"); + + migrationBuilder.DropTable( + name: "quotes"); + + migrationBuilder.DropTable( + name: "question"); + + migrationBuilder.DropTable( + name: "quizzes"); + + migrationBuilder.DropTable( + name: "characters"); + + migrationBuilder.DropTable( + name: "sources"); + + migrationBuilder.DropTable( + name: "users"); + + migrationBuilder.DropTable( + name: "images"); + } + } +} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/StubWTFContextModelSnapshot.cs b/WF_EF_Api/StubbedContextLib/Migrations/StubWTFContextModelSnapshot.cs index 4a848c7..21818ec 100644 --- a/WF_EF_Api/StubbedContextLib/Migrations/StubWTFContextModelSnapshot.cs +++ b/WF_EF_Api/StubbedContextLib/Migrations/StubWTFContextModelSnapshot.cs @@ -30,13 +30,213 @@ namespace StubbedContextLib.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + b.Property("IdImage") + .HasColumnType("int"); + b.Property("Name") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("IdImage"); + + b.ToTable("characters"); + + b.HasData( + new + { + Id = 1, + IdImage = 1, + Name = "Alan Grant" + }, + new + { + Id = 2, + IdImage = 2, + Name = "Aragorn" + }, + new + { + Id = 3, + IdImage = 3, + Name = "Legolas" + }, + new + { + Id = 4, + IdImage = 4, + Name = "Frodon" + }, + new + { + Id = 5, + IdImage = 5, + Name = "Dobby" + }, + new + { + Id = 6, + IdImage = 6, + Name = "Jon Snow" + }, + new + { + Id = 7, + IdImage = 7, + Name = "Daenerys Targaryen" + }, + new + { + Id = 8, + IdImage = 8, + Name = "Luke Skywalker" + }, + new + { + Id = 9, + IdImage = 9, + Name = "Princess Leia" + }, + new + { + Id = 10, + IdImage = 10, + Name = "Harry Potter" + }); + }); + + modelBuilder.Entity("Entity.Commentary", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Comment") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("DateCommentary") + .HasColumnType("date") + .HasColumnName("DateCommentary"); + + b.Property("IdQuote") + .HasColumnType("int"); + + b.Property("IdUsers") + .HasColumnType("int"); b.HasKey("Id"); - b.ToTable("Character"); + b.HasIndex("IdQuote"); + + b.HasIndex("IdUsers"); + + b.ToTable("comments"); + + b.HasData( + new + { + Id = 1, + Comment = "Ce film est le meilleur", + DateCommentary = new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), + IdQuote = 1, + IdUsers = 2 + }, + new + { + Id = 2, + Comment = "Very good", + DateCommentary = new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), + IdQuote = 1, + IdUsers = 3 + }); + }); + + modelBuilder.Entity("Entity.DailyQuote", b => + { + b.Property("IdQuote") + .HasColumnType("int"); + + b.HasKey("IdQuote"); + + b.ToTable("dailyquotes"); + + b.HasData( + new + { + IdQuote = 1 + }, + new + { + IdQuote = 5 + }); + }); + + modelBuilder.Entity("Entity.Favorite", b => + { + b.Property("IdQuote") + .HasColumnType("int"); + + b.Property("IdUsers") + .HasColumnType("int"); + + b.HasKey("IdQuote", "IdUsers"); + + b.HasIndex("IdUsers"); + + b.ToTable("favorites"); + + b.HasData( + new + { + IdQuote = 2, + IdUsers = 8 + }, + new + { + IdQuote = 5, + IdUsers = 3 + }, + new + { + IdQuote = 9, + IdUsers = 1 + }, + new + { + IdQuote = 4, + IdUsers = 10 + }, + new + { + IdQuote = 3, + IdUsers = 2 + }, + new + { + IdQuote = 6, + IdUsers = 7 + }, + new + { + IdQuote = 1, + IdUsers = 6 + }, + new + { + IdQuote = 8, + IdUsers = 9 + }, + new + { + IdQuote = 10, + IdUsers = 5 + }); }); modelBuilder.Entity("Entity.Images", b => @@ -53,18 +253,58 @@ namespace StubbedContextLib.Migrations b.HasKey("Id"); - b.ToTable("Images"); + b.ToTable("images"); b.HasData( new { Id = 1, - ImgPath = "coucou" + ImgPath = "https://th.bing.com/th/id/OIP.TJuWNCsibz8MVmhdNQEdMwHaE8?w=244&h=180&c=7&r=0&o=5&pid=1.7" }, new { Id = 2, - ImgPath = "bonjour" + ImgPath = "https://th.bing.com/th/id/OIP.NgXRQ5-IknA6_qOPFhLWIwHaHK?w=165&h=180&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 3, + ImgPath = "https://th.bing.com/th/id/OIP.XcJoJ6bC9sAMjol1pJn5UQHaLH?w=118&h=180&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 4, + ImgPath = "https://th.bing.com/th/id/OIP.PPIESqZaNDa-qUcfSDXhdQHaGK?w=210&h=180&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 5, + ImgPath = "https://th.bing.com/th/id/OIP.XBghSl2kfRNNtQoSxc901wHaHa?w=177&h=180&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 6, + ImgPath = "https://th.bing.com/th/id/OIP.af1Aid64cqEKoIOBgCPxtQHaJO?w=145&h=182&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 7, + ImgPath = "https://th.bing.com/th/id/OIP.ri5vSXr5lNTLt4DO6KQXyQHaI4?w=158&h=189&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 8, + ImgPath = "https://th.bing.com/th/id/OIP.uPTRLR8uspCiafiunUqKfQHaMJ?w=115&h=180&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 9, + ImgPath = "https://th.bing.com/th/id/OIP.hcJis4rKbyQtugsoFJU2ngHaM_?w=118&h=207&c=7&r=0&o=5&pid=1.7" + }, + new + { + Id = 10, + ImgPath = "https://th.bing.com/th/id/OIP.Py1_XfUrKJY_A6tYEmFS5wHaE8?w=280&h=187&c=7&r=0&o=5&pid=1.7" }); }); @@ -78,31 +318,139 @@ namespace StubbedContextLib.Migrations b.Property("AnswerA") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); b.Property("AnswerB") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); b.Property("AnswerC") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); b.Property("AnswerD") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); b.Property("CorrectAnswer") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(1) + .HasColumnType("nvarchar(1)"); b.Property("Text") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("Id"); - b.ToTable("Question"); + b.ToTable("question"); + + b.HasData( + new + { + Id = 1, + AnswerA = "Gimli", + AnswerB = "Aragorn", + AnswerC = "Frodon", + AnswerD = "Gandalf", + CorrectAnswer = "B", + Text = "Qui est le leader de la Communauté de l'Anneau ?" + }, + new + { + Id = 2, + AnswerA = "Serdaigle", + AnswerB = "Gryffondor", + AnswerC = "Serpentard", + AnswerD = "Poufsouffle", + CorrectAnswer = "B", + Text = "Dans quelle maison Harry Potter est-il ?" + }, + new + { + Id = 3, + AnswerA = "Saroumane", + AnswerB = "Sauron", + AnswerC = "Gollum", + AnswerD = "Gothmog", + CorrectAnswer = "B", + Text = "Qui est le Seigneur des Ténèbres dans la saga Le Seigneur des Anneaux ?" + }, + new + { + Id = 4, + AnswerA = "Han Solo", + AnswerB = "Princesse Leia", + AnswerC = "Chewbacca", + AnswerD = "R2-D2", + CorrectAnswer = "A", + Text = "Dans le film Star Wars : Episode IV, qui sauve Luke Skywalker de l'Étoile de la Mort ?" + }, + new + { + Id = 5, + AnswerA = "Reine Jadis", + AnswerB = "Aslan", + AnswerC = "Edmund", + AnswerD = "Lucy", + CorrectAnswer = "B", + Text = "Qui est le souverain de Narnia dans Le Lion, la Sorcière Blanche et l'Armoire Magique ?" + }, + new + { + Id = 6, + AnswerA = "Smaug", + AnswerB = "Falkor", + AnswerC = "Norbert", + AnswerD = "Shenron", + CorrectAnswer = "A", + Text = "Quel est le nom du dragon dans Le Hobbit ?" + }, + new + { + Id = 7, + AnswerA = "Bella Swan", + AnswerB = "Edward Cullen", + AnswerC = "Jacob Black", + AnswerD = "Victoria", + CorrectAnswer = "A", + Text = "Qui est la première personne à être mordue par un vampire dans Twilight ?" + }, + new + { + Id = 8, + AnswerA = "Obi-Wan Kenobi", + AnswerB = "Yoda", + AnswerC = "Han Solo", + AnswerD = "Luke Skywalker", + CorrectAnswer = "A", + Text = "Quel personnage dit Que la Force soit avec toi dans Star Wars ?" + }, + new + { + Id = 9, + AnswerA = "Dr. Ellie Sattler", + AnswerB = "Alan Grant", + AnswerC = "John Hammond", + AnswerD = "Dennis Nedry", + CorrectAnswer = "B", + Text = "Dans Jurassic Park, quel est le nom du paléontologue sur l'île ?" + }, + new + { + Id = 10, + AnswerA = "Cersei Lannister", + AnswerB = "Arya Stark", + AnswerC = "Daenerys Targaryen", + AnswerD = "Sansa Stark", + CorrectAnswer = "C", + Text = "Dans Game of Thrones, qui est surnommée la Mère des Dragons ?" + }); }); modelBuilder.Entity("Entity.Quiz", b => @@ -113,16 +461,105 @@ namespace StubbedContextLib.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + b.Property("IdImage") + .HasColumnType("int"); + b.Property("NbQuestion") .HasColumnType("int"); b.Property("Title") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); b.HasKey("Id"); - b.ToTable("Quiz"); + b.HasIndex("IdImage"); + + b.ToTable("quizzes"); + + b.HasData( + new + { + Id = 1, + IdImage = 1, + NbQuestion = 5, + Title = "Quiz 1" + }, + new + { + Id = 2, + IdImage = 2, + NbQuestion = 5, + Title = "Quiz 2" + }); + }); + + modelBuilder.Entity("Entity.QuizQuestion", b => + { + b.Property("IdQuestion") + .HasColumnType("int"); + + b.Property("IdQuiz") + .HasColumnType("int"); + + b.HasKey("IdQuestion", "IdQuiz"); + + b.HasIndex("IdQuiz"); + + b.ToTable("QuizQuestion"); + + b.HasData( + new + { + IdQuestion = 1, + IdQuiz = 1 + }, + new + { + IdQuestion = 2, + IdQuiz = 1 + }, + new + { + IdQuestion = 3, + IdQuiz = 1 + }, + new + { + IdQuestion = 4, + IdQuiz = 1 + }, + new + { + IdQuestion = 5, + IdQuiz = 1 + }, + new + { + IdQuestion = 6, + IdQuiz = 2 + }, + new + { + IdQuestion = 7, + IdQuiz = 2 + }, + new + { + IdQuestion = 8, + IdQuiz = 2 + }, + new + { + IdQuestion = 9, + IdQuiz = 2 + }, + new + { + IdQuestion = 10, + IdQuiz = 2 + }); }); modelBuilder.Entity("Entity.Quote", b => @@ -135,7 +572,17 @@ namespace StubbedContextLib.Migrations b.Property("Content") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IdCharacter") + .HasColumnType("int"); + + b.Property("IdSource") + .HasColumnType("int"); + + b.Property("IdUsersPropose") + .HasColumnType("int"); b.Property("IsValid") .HasColumnType("bit"); @@ -148,7 +595,125 @@ namespace StubbedContextLib.Migrations b.HasKey("Id"); - b.ToTable("Quote"); + b.HasIndex("IdCharacter"); + + b.HasIndex("IdSource"); + + b.HasIndex("IdUsersPropose"); + + b.ToTable("quotes"); + + b.HasData( + new + { + Id = 1, + Content = "Je n'y crois pas. Je n'y crois pas. Ce n'est pas possible", + IdCharacter = 1, + IdSource = 1, + IdUsersPropose = 1, + IsValid = true, + Langage = 1, + Likes = 11025 + }, + new + { + Id = 2, + Content = "There is always hope", + IdCharacter = 2, + IdSource = 2, + IdUsersPropose = 1, + IsValid = true, + Langage = 0, + Likes = 11025 + }, + new + { + Id = 3, + Content = "A red sun rises. Blood has been spilled this night.", + IdCharacter = 3, + IdSource = 2, + IdUsersPropose = 1, + IsValid = true, + Langage = 0, + Likes = 11025 + }, + new + { + Id = 4, + Content = "I wish the Ring had never come to me.I wish none of this had happened.", + IdCharacter = 4, + IdSource = 2, + IdUsersPropose = 1, + IsValid = true, + Langage = 0, + Likes = 11025 + }, + new + { + Id = 5, + Content = "Dobby is a free elf!", + IdCharacter = 5, + IdSource = 4, + IdUsersPropose = 1, + IsValid = true, + Langage = 0, + Likes = 11025 + }, + new + { + Id = 6, + Content = "Winter is comming", + IdCharacter = 6, + IdSource = 3, + IdUsersPropose = 1, + IsValid = true, + Langage = 0, + Likes = 11025 + }, + new + { + Id = 7, + Content = "Je suis la dernière Targaryen. Je suis la reine des dragons", + IdCharacter = 7, + IdSource = 3, + IdUsersPropose = 1, + IsValid = true, + Langage = 1, + Likes = 11025 + }, + new + { + Id = 8, + Content = "Je ne suis pas prêt à affronter ça. C'est trop pour moi.", + IdCharacter = 8, + IdSource = 5, + IdUsersPropose = 1, + IsValid = true, + Langage = 1, + Likes = 11025 + }, + new + { + Id = 9, + Content = "Aidez-moi, Obi-Wan Kenobi, vous êtes mon seul espoir.", + IdCharacter = 9, + IdSource = 5, + IdUsersPropose = 1, + IsValid = true, + Langage = 1, + Likes = 11025 + }, + new + { + Id = 10, + Content = "La quoi ?", + IdCharacter = 10, + IdSource = 4, + IdUsersPropose = 1, + IsValid = true, + Langage = 1, + Likes = 11025 + }); }); modelBuilder.Entity("Entity.Source", b => @@ -161,14 +726,55 @@ namespace StubbedContextLib.Migrations b.Property("Title") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TypeSrc") + .HasColumnType("int"); b.Property("Year") .HasColumnType("int"); b.HasKey("Id"); - b.ToTable("Source"); + b.ToTable("sources"); + + b.HasData( + new + { + Id = 1, + Title = "Jurassic Park", + TypeSrc = 0, + Year = 1993 + }, + new + { + Id = 2, + Title = "Le Seigneur des anneaux : La Communauté de l'anneau", + TypeSrc = 0, + Year = 2001 + }, + new + { + Id = 3, + Title = "Game of throne", + TypeSrc = 1, + Year = 2011 + }, + new + { + Id = 4, + Title = "Harry Potter à l'école des sorcier", + TypeSrc = 0, + Year = 1997 + }, + new + { + Id = 5, + Title = "Star Wars, épisode IV : Un nouvel espoir", + TypeSrc = 0, + Year = 1977 + }); }); modelBuilder.Entity("Entity.Users", b => @@ -180,50 +786,239 @@ namespace StubbedContextLib.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("Created") - .HasColumnType("datetime2"); + .HasColumnType("date") + .HasColumnName("Created"); b.Property("Email") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); b.Property("IdImage") .HasColumnType("int"); b.Property("Password") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("UserName") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); b.HasKey("Id"); b.HasIndex("IdImage"); - b.ToTable("Users"); + b.ToTable("users"); b.HasData( new { Id = 1, - Created = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "dev@gmail.com", + Created = new DateTime(2025, 5, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "jhonDhoe@gmail.com", IdImage = 1, Password = "1234", - UserName = "Dev" + UserName = "Jhon-Dhoe" }, new { Id = 2, - Created = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "admin@gmail.com", - IdImage = 1, - Password = "1234", - UserName = "Admin" + Created = new DateTime(2025, 3, 19, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "lucy_rose@outlook.com", + IdImage = 2, + Password = "abcd", + UserName = "Lucy-Rose" + }, + new + { + Id = 3, + Created = new DateTime(2024, 11, 2, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "mark.taylor@yahoo.com", + IdImage = 3, + Password = "5678", + UserName = "Mark-Taylor" + }, + new + { + Id = 4, + Created = new DateTime(2025, 2, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "sophie.martin@gmail.com", + IdImage = 4, + Password = "4321", + UserName = "Sophie-Martin" + }, + new + { + Id = 5, + Created = new DateTime(2025, 1, 15, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "nathan_doe@aol.com", + IdImage = 5, + Password = "8765", + UserName = "Nathan-Doe" + }, + new + { + Id = 6, + Created = new DateTime(2025, 4, 7, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "ella.brown@icloud.com", + IdImage = 6, + Password = "2468", + UserName = "Ella-Brown" + }, + new + { + Id = 7, + Created = new DateTime(2024, 12, 25, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "oliver_smith@gmail.com", + IdImage = 7, + Password = "1357", + UserName = "Oliver-Smith" + }, + new + { + Id = 8, + Created = new DateTime(2025, 3, 5, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "mia.jones@outlook.com", + IdImage = 8, + Password = "1122", + UserName = "Mia-Jones" + }, + new + { + Id = 9, + Created = new DateTime(2025, 2, 22, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "kevin_williams@aol.com", + IdImage = 9, + Password = "2233", + UserName = "Kevin-Williams" + }, + new + { + Id = 10, + Created = new DateTime(2025, 1, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "olivia.white@yahoo.com", + IdImage = 10, + Password = "3344", + UserName = "Olivia-White" }); }); + modelBuilder.Entity("Entity.Character", b => + { + b.HasOne("Entity.Images", "Images") + .WithMany("Characters") + .HasForeignKey("IdImage") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Images"); + }); + + modelBuilder.Entity("Entity.Commentary", b => + { + b.HasOne("Entity.Quote", "Quote") + .WithMany("commentaries") + .HasForeignKey("IdQuote") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entity.Users", "Users") + .WithMany("Commentary") + .HasForeignKey("IdUsers") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Quote"); + + b.Navigation("Users"); + }); + + modelBuilder.Entity("Entity.DailyQuote", b => + { + b.HasOne("Entity.Quote", "Quote") + .WithMany("DailyQuotes") + .HasForeignKey("IdQuote") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Quote"); + }); + + modelBuilder.Entity("Entity.Favorite", b => + { + b.HasOne("Entity.Quote", "Quote") + .WithMany() + .HasForeignKey("IdQuote") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entity.Users", "Users") + .WithMany() + .HasForeignKey("IdUsers") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Quote"); + + b.Navigation("Users"); + }); + + modelBuilder.Entity("Entity.Quiz", b => + { + b.HasOne("Entity.Images", "Images") + .WithMany("Quizs") + .HasForeignKey("IdImage") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Images"); + }); + + modelBuilder.Entity("Entity.QuizQuestion", b => + { + b.HasOne("Entity.Question", null) + .WithMany() + .HasForeignKey("IdQuestion") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entity.Quiz", null) + .WithMany() + .HasForeignKey("IdQuiz") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entity.Quote", b => + { + b.HasOne("Entity.Character", "Character") + .WithMany("Quotes") + .HasForeignKey("IdCharacter") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entity.Source", "Source") + .WithMany("Quotes") + .HasForeignKey("IdSource") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entity.Users", "User") + .WithMany("Quotes") + .HasForeignKey("IdUsersPropose") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Character"); + + b.Navigation("Source"); + + b.Navigation("User"); + }); + modelBuilder.Entity("Entity.Users", b => { b.HasOne("Entity.Images", "Images") @@ -235,10 +1030,38 @@ namespace StubbedContextLib.Migrations b.Navigation("Images"); }); + modelBuilder.Entity("Entity.Character", b => + { + b.Navigation("Quotes"); + }); + modelBuilder.Entity("Entity.Images", b => { + b.Navigation("Characters"); + + b.Navigation("Quizs"); + b.Navigation("Users"); }); + + modelBuilder.Entity("Entity.Quote", b => + { + b.Navigation("DailyQuotes"); + + b.Navigation("commentaries"); + }); + + modelBuilder.Entity("Entity.Source", b => + { + b.Navigation("Quotes"); + }); + + modelBuilder.Entity("Entity.Users", b => + { + b.Navigation("Commentary"); + + b.Navigation("Quotes"); + }); #pragma warning restore 612, 618 } } diff --git a/WF_EF_Api/StubbedContextLib/StubWTFContext.cs b/WF_EF_Api/StubbedContextLib/StubWTFContext.cs index bd533d8..6df9912 100644 --- a/WF_EF_Api/StubbedContextLib/StubWTFContext.cs +++ b/WF_EF_Api/StubbedContextLib/StubWTFContext.cs @@ -19,6 +19,32 @@ namespace StubbedContextLib new Admin() { IdUsers = 1 } );*/ + modelBuilder.Entity().HasData( + new Images() { Id = 1, ImgPath = "https://th.bing.com/th/id/OIP.TJuWNCsibz8MVmhdNQEdMwHaE8?w=244&h=180&c=7&r=0&o=5&pid=1.7" }, + new Images() { Id = 2, ImgPath = "https://th.bing.com/th/id/OIP.NgXRQ5-IknA6_qOPFhLWIwHaHK?w=165&h=180&c=7&r=0&o=5&pid=1.7" }, + new Images() { Id = 3, ImgPath = "https://th.bing.com/th/id/OIP.XcJoJ6bC9sAMjol1pJn5UQHaLH?w=118&h=180&c=7&r=0&o=5&pid=1.7" }, + new Images() { Id = 4, ImgPath = "https://th.bing.com/th/id/OIP.PPIESqZaNDa-qUcfSDXhdQHaGK?w=210&h=180&c=7&r=0&o=5&pid=1.7" }, + new Images() { Id = 5, ImgPath = "https://th.bing.com/th/id/OIP.XBghSl2kfRNNtQoSxc901wHaHa?w=177&h=180&c=7&r=0&o=5&pid=1.7" }, + new Images() { Id = 6, ImgPath = "https://th.bing.com/th/id/OIP.af1Aid64cqEKoIOBgCPxtQHaJO?w=145&h=182&c=7&r=0&o=5&pid=1.7" }, + new Images() { Id = 7, ImgPath = "https://th.bing.com/th/id/OIP.ri5vSXr5lNTLt4DO6KQXyQHaI4?w=158&h=189&c=7&r=0&o=5&pid=1.7" }, + new Images() { Id = 8, ImgPath = "https://th.bing.com/th/id/OIP.uPTRLR8uspCiafiunUqKfQHaMJ?w=115&h=180&c=7&r=0&o=5&pid=1.7" }, + new Images() { Id = 9, ImgPath = "https://th.bing.com/th/id/OIP.hcJis4rKbyQtugsoFJU2ngHaM_?w=118&h=207&c=7&r=0&o=5&pid=1.7" }, + new Images() { Id = 10, ImgPath = "https://th.bing.com/th/id/OIP.Py1_XfUrKJY_A6tYEmFS5wHaE8?w=280&h=187&c=7&r=0&o=5&pid=1.7" } + ); + + modelBuilder.Entity().HasData( + new Users() { Id = 1, Email = "jhonDhoe@gmail.com", Password = "1234", Created = new DateTime(2025, 5, 12), UserName = "Jhon-Dhoe", IdImage = 1 }, + new Users() { Id = 2, Email = "lucy_rose@outlook.com", Password = "abcd", Created = new DateTime(2025, 3, 19), UserName = "Lucy-Rose", IdImage = 2 }, + new Users() { Id = 3, Email = "mark.taylor@yahoo.com", Password = "5678", Created = new DateTime(2024, 11, 2), UserName = "Mark-Taylor", IdImage = 3 }, + new Users() { Id = 4, Email = "sophie.martin@gmail.com", Password = "4321", Created = new DateTime(2025, 2, 28), UserName = "Sophie-Martin", IdImage = 4 }, + new Users() { Id = 5, Email = "nathan_doe@aol.com", Password = "8765", Created = new DateTime(2025, 1, 15), UserName = "Nathan-Doe", IdImage = 5 }, + new Users() { Id = 6, Email = "ella.brown@icloud.com", Password = "2468", Created = new DateTime(2025, 4, 7), UserName = "Ella-Brown", IdImage = 6 }, + new Users() { Id = 7, Email = "oliver_smith@gmail.com", Password = "1357", Created = new DateTime(2024, 12, 25), UserName = "Oliver-Smith", IdImage = 7 }, + new Users() { Id = 8, Email = "mia.jones@outlook.com", Password = "1122", Created = new DateTime(2025, 3, 5), UserName = "Mia-Jones", IdImage = 8 }, + new Users() { Id = 9, Email = "kevin_williams@aol.com", Password = "2233", Created = new DateTime(2025, 2, 22), UserName = "Kevin-Williams", IdImage = 9 }, + new Users() { Id = 10, Email = "olivia.white@yahoo.com", Password = "3344", Created = new DateTime(2025, 1, 3), UserName = "Olivia-White", IdImage = 10 } + ); + modelBuilder.Entity().HasData( new Character() { Id = 1 , Name = "Alan Grant", IdImage = 1}, new Character() { Id = 2, Name = "Aragorn", IdImage = 2 }, @@ -32,6 +58,19 @@ namespace StubbedContextLib new Character() { Id = 10, Name = "Harry Potter", IdImage = 10 } ); + modelBuilder.Entity().HasData( + new Quote() { Id = 1, Content = "Je n'y crois pas. Je n'y crois pas. Ce n'est pas possible", IdCharacter = 1, IdSource = 1, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 }, + new Quote() { Id = 2, Content = "There is always hope", IdCharacter = 2, IdSource = 2, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 }, + new Quote() { Id = 3, Content = "A red sun rises. Blood has been spilled this night.", IdCharacter = 3, IdSource = 2, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 }, + new Quote() { Id = 4, Content = "I wish the Ring had never come to me.I wish none of this had happened.", IdCharacter = 4, IdSource = 2, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 }, + new Quote() { Id = 5, Content = "Dobby is a free elf!", IdCharacter = 5, IdSource = 4, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 }, + new Quote() { Id = 6, Content = "Winter is comming", IdCharacter = 6, IdSource = 3, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 }, + new Quote() { Id = 7, Content = "Je suis la dernière Targaryen. Je suis la reine des dragons", IdCharacter = 7, IdSource = 3, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 }, + new Quote() { Id = 8, Content = "Je ne suis pas prêt à affronter ça. C'est trop pour moi.", IdCharacter = 8, IdSource = 5, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 }, + new Quote() { Id = 9, Content = "Aidez-moi, Obi-Wan Kenobi, vous êtes mon seul espoir.", IdCharacter = 9, IdSource = 5, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 }, + new Quote() { Id = 10, Content = "La quoi ?", IdCharacter = 10, IdSource = 4, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 } + ); + modelBuilder.Entity().HasData( new Commentary() { Id = 1, Comment = "Ce film est le meilleur", DateCommentary = new DateTime(2025,2,3), IdQuote = 1, IdUsers = 2 }, new Commentary() { Id = 2, Comment = "Very good", DateCommentary = new DateTime(2025, 3, 11), IdQuote = 1, IdUsers = 3 } @@ -54,35 +93,24 @@ namespace StubbedContextLib new Favorite() { IdQuote = 10, IdUsers = 5 } ); - modelBuilder.Entity().HasData( - new Images() { Id = 1 , ImgPath = "https://th.bing.com/th/id/OIP.TJuWNCsibz8MVmhdNQEdMwHaE8?w=244&h=180&c=7&r=0&o=5&pid=1.7" }, - new Images() { Id = 2 , ImgPath = "https://th.bing.com/th/id/OIP.NgXRQ5-IknA6_qOPFhLWIwHaHK?w=165&h=180&c=7&r=0&o=5&pid=1.7" }, - new Images() { Id = 3 , ImgPath = "https://th.bing.com/th/id/OIP.XcJoJ6bC9sAMjol1pJn5UQHaLH?w=118&h=180&c=7&r=0&o=5&pid=1.7" }, - new Images() { Id = 4 , ImgPath = "https://th.bing.com/th/id/OIP.PPIESqZaNDa-qUcfSDXhdQHaGK?w=210&h=180&c=7&r=0&o=5&pid=1.7" }, - new Images() { Id = 5 , ImgPath = "https://th.bing.com/th/id/OIP.XBghSl2kfRNNtQoSxc901wHaHa?w=177&h=180&c=7&r=0&o=5&pid=1.7" }, - new Images() { Id = 6 , ImgPath = "https://th.bing.com/th/id/OIP.af1Aid64cqEKoIOBgCPxtQHaJO?w=145&h=182&c=7&r=0&o=5&pid=1.7" }, - new Images() { Id = 7 , ImgPath = "https://th.bing.com/th/id/OIP.ri5vSXr5lNTLt4DO6KQXyQHaI4?w=158&h=189&c=7&r=0&o=5&pid=1.7" }, - new Images() { Id = 8 , ImgPath = "https://th.bing.com/th/id/OIP.uPTRLR8uspCiafiunUqKfQHaMJ?w=115&h=180&c=7&r=0&o=5&pid=1.7" }, - new Images() { Id = 9 , ImgPath = "https://th.bing.com/th/id/OIP.hcJis4rKbyQtugsoFJU2ngHaM_?w=118&h=207&c=7&r=0&o=5&pid=1.7" }, - new Images() { Id = 10 , ImgPath = "https://th.bing.com/th/id/OIP.Py1_XfUrKJY_A6tYEmFS5wHaE8?w=280&h=187&c=7&r=0&o=5&pid=1.7" } - ); + modelBuilder.Entity().HasData( new Question() { Id = 1, Text = "Qui est le leader de la Communauté de l'Anneau ?", AnswerA = "Gimli", AnswerB = "Aragorn", AnswerC = "Frodon", AnswerD = "Gandalf", CorrectAnswer = "B" }, new Question() { Id = 2, Text = "Dans quelle maison Harry Potter est-il ?", AnswerA = "Serdaigle", AnswerB = "Gryffondor", AnswerC = "Serpentard", AnswerD = "Poufsouffle", CorrectAnswer = "B" }, - new Question() { Id = 3, Text = "Qui est le Seigneur des Ténèbres dans la saga 'Le Seigneur des Anneaux' ?", AnswerA = "Saroumane", AnswerB = "Sauron", AnswerC = "Gollum", AnswerD = "Gothmog", CorrectAnswer = "B" }, - new Question() { Id = 4, Text = "Dans le film 'Star Wars : Episode IV', qui sauve Luke Skywalker de l'Étoile de la Mort ?", AnswerA = "Han Solo", AnswerB = "Princesse Leia", AnswerC = "Chewbacca", AnswerD = "R2-D2", CorrectAnswer = "A" }, - new Question() { Id = 5, Text = "Qui est le souverain de Narnia dans 'Le Lion, la Sorcière Blanche et l'Armoire Magique' ?", AnswerA = "Reine Jadis", AnswerB = "Aslan", AnswerC = "Edmund", AnswerD = "Lucy", CorrectAnswer = "B" }, - new Question() { Id = 6, Text = "Quel est le nom du dragon dans 'Le Hobbit' ?", AnswerA = "Smaug", AnswerB = "Falkor", AnswerC = "Norbert", AnswerD = "Shenron", CorrectAnswer = "A" }, - new Question() { Id = 7, Text = "Qui est la première personne à être mordue par un vampire dans 'Twilight' ?", AnswerA = "Bella Swan", AnswerB = "Edward Cullen", AnswerC = "Jacob Black", AnswerD = "Victoria", CorrectAnswer = "A" }, - new Question() { Id = 8, Text = "Quel personnage dit 'Que la Force soit avec toi' dans 'Star Wars' ?", AnswerA = "Obi-Wan Kenobi", AnswerB = "Yoda", AnswerC = "Han Solo", AnswerD = "Luke Skywalker", CorrectAnswer = "A" }, - new Question() { Id = 9, Text = "Dans 'Jurassic Park', quel est le nom du paléontologue sur l'île ?", AnswerA = "Dr. Ellie Sattler", AnswerB = "Alan Grant", AnswerC = "John Hammond", AnswerD = "Dennis Nedry", CorrectAnswer = "B" }, - new Question() { Id = 10, Text = "Dans 'Game of Thrones', qui est surnommée la Mère des Dragons ?", AnswerA = "Cersei Lannister", AnswerB = "Arya Stark", AnswerC = "Daenerys Targaryen", AnswerD = "Sansa Stark", CorrectAnswer = "C" } + new Question() { Id = 3, Text = "Qui est le Seigneur des Ténèbres dans la saga Le Seigneur des Anneaux ?", AnswerA = "Saroumane", AnswerB = "Sauron", AnswerC = "Gollum", AnswerD = "Gothmog", CorrectAnswer = "B" }, + new Question() { Id = 4, Text = "Dans le film Star Wars : Episode IV, qui sauve Luke Skywalker de l'Étoile de la Mort ?", AnswerA = "Han Solo", AnswerB = "Princesse Leia", AnswerC = "Chewbacca", AnswerD = "R2-D2", CorrectAnswer = "A" }, + new Question() { Id = 5, Text = "Qui est le souverain de Narnia dans Le Lion, la Sorcière Blanche et l'Armoire Magique ?", AnswerA = "Reine Jadis", AnswerB = "Aslan", AnswerC = "Edmund", AnswerD = "Lucy", CorrectAnswer = "B" }, + new Question() { Id = 6, Text = "Quel est le nom du dragon dans Le Hobbit ?", AnswerA = "Smaug", AnswerB = "Falkor", AnswerC = "Norbert", AnswerD = "Shenron", CorrectAnswer = "A" }, + new Question() { Id = 7, Text = "Qui est la première personne à être mordue par un vampire dans Twilight ?", AnswerA = "Bella Swan", AnswerB = "Edward Cullen", AnswerC = "Jacob Black", AnswerD = "Victoria", CorrectAnswer = "A" }, + new Question() { Id = 8, Text = "Quel personnage dit Que la Force soit avec toi dans Star Wars ?", AnswerA = "Obi-Wan Kenobi", AnswerB = "Yoda", AnswerC = "Han Solo", AnswerD = "Luke Skywalker", CorrectAnswer = "A" }, + new Question() { Id = 9, Text = "Dans Jurassic Park, quel est le nom du paléontologue sur l'île ?", AnswerA = "Dr. Ellie Sattler", AnswerB = "Alan Grant", AnswerC = "John Hammond", AnswerD = "Dennis Nedry", CorrectAnswer = "B" }, + new Question() { Id = 10, Text = "Dans Game of Thrones, qui est surnommée la Mère des Dragons ?", AnswerA = "Cersei Lannister", AnswerB = "Arya Stark", AnswerC = "Daenerys Targaryen", AnswerD = "Sansa Stark", CorrectAnswer = "C" } ); modelBuilder.Entity().HasData( new Quiz() { Id = 1, IdImage = 1, Title = "Quiz 1", NbQuestion = 5 }, - new Quiz() { Id = 1, IdImage = 2, Title = "Quiz 2", NbQuestion = 5 } + new Quiz() { Id = 2, IdImage = 2, Title = "Quiz 2", NbQuestion = 5 } ); modelBuilder.Entity().HasData( @@ -98,20 +126,6 @@ namespace StubbedContextLib new QuizQuestion() { IdQuestion = 10, IdQuiz = 2 } ); - modelBuilder.Entity().HasData( - new Quote() { Id = 1, Content = "Je n'y crois pas. Je n'y crois pas. Ce n'est pas possible", IdCharacter = 1, IdSource = 1, IdUsersPropose = 1 , IsValid = true, Langage = LangEnum.vf, Likes = 11025}, - new Quote() { Id = 2, Content = "There is always hope", IdCharacter = 2, IdSource = 2, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 }, - new Quote() { Id = 3, Content = "A red sun rises. Blood has been spilled this night.", IdCharacter = 3, IdSource = 2, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 }, - new Quote() { Id = 4, Content = "I wish the Ring had never come to me.I wish none of this had happened.", IdCharacter = 4, IdSource = 2, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 }, - new Quote() { Id = 5, Content = "Dobby is a free elf!", IdCharacter = 5 , IdSource = 4 , IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 }, - new Quote() { Id = 6, Content = "Winter is comming", IdCharacter = 6 , IdSource = 3, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 }, - new Quote() { Id = 7, Content = "Je suis la dernière Targaryen. Je suis la reine des dragons", IdCharacter = 7 , IdSource = 3, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 }, - new Quote() { Id = 8, Content = "Je ne suis pas prêt à affronter ça. C'est trop pour moi.", IdCharacter = 8 , IdSource = 5, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 }, - new Quote() { Id = 9, Content = "Aidez-moi, Obi-Wan Kenobi, vous êtes mon seul espoir.", IdCharacter = 9 , IdSource = 5, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 }, - new Quote() { Id = 10, Content = "La quoi ?", IdCharacter = 10 , IdSource = 4 , IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 } - ); - - modelBuilder.Entity().HasData( new Source() { Id = 1, Title = "Jurassic Park", TypeSrc = TypeSrcEnum.movie, Year = 1993 }, new Source() { Id = 2, Title = "Le Seigneur des anneaux : La Communauté de l'anneau", TypeSrc = TypeSrcEnum.movie, Year = 2001 }, @@ -120,18 +134,7 @@ namespace StubbedContextLib new Source() { Id = 5, Title = "Star Wars, épisode IV : Un nouvel espoir", TypeSrc = TypeSrcEnum.movie, Year = 1977 } ); - modelBuilder.Entity().HasData( - new Users() { Id = 1, Email = "jhonDhoe@gmail.com", Password = "1234", Created = new DateTime(2025, 5, 12), UserName = "Jhon-Dhoe", IdImage = 1 }, - new Users() { Id = 2, Email = "lucy_rose@outlook.com", Password = "abcd", Created = new DateTime(2025, 3, 19), UserName = "Lucy-Rose", IdImage = 2 }, - new Users() { Id = 3, Email = "mark.taylor@yahoo.com", Password = "5678", Created = new DateTime(2024, 11, 2), UserName = "Mark-Taylor", IdImage = 3 }, - new Users() { Id = 4, Email = "sophie.martin@gmail.com", Password = "4321", Created = new DateTime(2025, 2, 28), UserName = "Sophie-Martin", IdImage = 4 }, - new Users() { Id = 5, Email = "nathan_doe@aol.com", Password = "8765", Created = new DateTime(2025, 1, 15), UserName = "Nathan-Doe", IdImage = 5 }, - new Users() { Id = 6, Email = "ella.brown@icloud.com", Password = "2468", Created = new DateTime(2025, 4, 7), UserName = "Ella-Brown", IdImage = 6 }, - new Users() { Id = 7, Email = "oliver_smith@gmail.com", Password = "1357", Created = new DateTime(2024, 12, 25), UserName = "Oliver-Smith", IdImage = 7 }, - new Users() { Id = 8, Email = "mia.jones@outlook.com", Password = "1122", Created = new DateTime(2025, 3, 5), UserName = "Mia-Jones", IdImage = 8 }, - new Users() { Id = 9, Email = "kevin_williams@aol.com", Password = "2233", Created = new DateTime(2025, 2, 22), UserName = "Kevin-Williams", IdImage = 9 }, - new Users() { Id = 10, Email = "olivia.white@yahoo.com", Password = "3344", Created = new DateTime(2025, 1, 3), UserName = "Olivia-White", IdImage = 10 } - ); + }