diff --git a/.drone.yml b/.drone.yml index ed13d1e..894663d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,82 +1,82 @@ -kind: pipeline -type: docker -name: CI_ApiPm - -trigger: - event: - - push - branch: - exclude: - - master - -steps: - - name: retore & build - image: mcr.microsoft.com/dotnet/sdk:8.0 - commands: - - dotnet build --configuration Release - depend_on: [clone] - - - name: test - image: mcr.microsoft.com/dotnet/sdk:8.0 - commands: - - dotnet test - depends_on: [retore & build] - - - name: publish - image: mcr.microsoft.com/dotnet/sdk:8.0 - commands: - - dotnet publish -c Release -o out - depends_on: [retore & build, test] - ---- - -kind: pipeline -type: docker -name: CI_ApiPm_Master - -trigger: - event: - - push - branch: - - master - -volumes: - - name: doc - temp: {} - - -steps: - - name: retore & build - image: mcr.microsoft.com/dotnet/sdk:8.0 - commands: - - dotnet build --configuration Release - depend_on: [clone] - - - name: test - image: mcr.microsoft.com/dotnet/sdk:8.0 - commands: - - dotnet test - depends_on: [retore & build] - - - name: generate doc - image: mcr.microsoft.com/dotnet/sdk:8.0 - volumes: - - name: doc - path: /doc - commands: - - dotnet new tool-manifest - - dotnet tool install NSwag.ConsoleCore - - dotnet restore - - cd WF_EF_Api/WfApi - - dotnet nswag aspnetcore2openapi /output:/doc/swagger.json - depends_on: [clone, retore & build] - - #- name: code-inspection - # image: hub.codefirst.iut.uca.fr/marc.chevaldonne:codefirs-dronsonarplugin-dotnet8 - # secret: [SECRET_SONAR_LOGIN] - # A FINIR - - name: publish - image: mcr.microsoft.com/dotnet/sdk:8.0 - commands: - - dotnet publish -c Release -o out +kind: pipeline +type: docker +name: CI_ApiPm + +trigger: + event: + - push + branch: + exclude: + - master + +steps: + - name: retore & build + image: mcr.microsoft.com/dotnet/sdk:8.0 + commands: + - dotnet build WF_EF_Api/WF_EF_Api.sln --configuration Release + depend_on: [clone] + + - name: test + image: mcr.microsoft.com/dotnet/sdk:8.0 + commands: + - dotnet test WF_EF_Api/XUnitTest/XUnitTest.csproj + depends_on: [retore & build] + + - name: publish + image: mcr.microsoft.com/dotnet/sdk:8.0 + commands: + - dotnet publish WF_EF_Api/WfApi/WfApi.csproj -c Release -o out + depends_on: [retore & build, test] + +--- + +kind: pipeline +type: docker +name: CI_ApiPm_Master + +trigger: + event: + - push + branch: + - master + +volumes: + - name: doc + temp: {} + + +steps: + - name: retore & build + image: mcr.microsoft.com/dotnet/sdk:8.0 + commands: + - dotnet build --configuration Release + depend_on: [clone] + + - name: test + image: mcr.microsoft.com/dotnet/sdk:8.0 + commands: + - dotnet test + depends_on: [retore & build] + + - name: generate doc + image: mcr.microsoft.com/dotnet/sdk:8.0 + volumes: + - name: doc + path: /doc + commands: + - dotnet new tool-manifest + - dotnet tool install NSwag.ConsoleCore + - dotnet restore + - cd WF_EF_Api/WfApi + - dotnet nswag aspnetcore2openapi /output:/doc/swagger.json + depends_on: [clone, retore & build] + + #- name: code-inspection + # image: hub.codefirst.iut.uca.fr/marc.chevaldonne:codefirs-dronsonarplugin-dotnet8 + # secret: [SECRET_SONAR_LOGIN] + # A FINIR + - name: publish + image: mcr.microsoft.com/dotnet/sdk:8.0 + commands: + - dotnet publish -c Release -o out depends_on: [retore & build, test] \ No newline at end of file diff --git a/WF_EF_Api/Contextlib/DbCommentaryManager.cs b/WF_EF_Api/Contextlib/DbCommentaryManager.cs index 78f7ae4..bac04e3 100644 --- a/WF_EF_Api/Contextlib/DbCommentaryManager.cs +++ b/WF_EF_Api/Contextlib/DbCommentaryManager.cs @@ -38,20 +38,28 @@ namespace Contextlib .Include(q => q.Commentarys) // collection des commentaires est chargée .FirstOrDefaultAsync(q => q.Id == idQuote); + var dbU = new DbUsersManager(_context); + var User = await dbU.GetUserByUsername(comment.User.UserName); + if (User == null) + { + throw new ArgumentException("Quote not exist", nameof(comment.User.UserName)); + } + if (quote == null) { throw new ArgumentException("Quote not exist", nameof(idQuote)); } + comment.User = User; + comment.IdUser = User.Id; + // Lien entre le commentaire et la citation comment.Quote = quote; comment.IdQuote = idQuote; - // Ajout commentaire à la collection des commentaires de la citation - quote.Commentarys.Add(comment); - - - _repo.Insert(comment); + // Ajout commentaire à la collection des commentaires de la citation + //_repo.Insert(comment); + _context.Add(comment); await _context.SaveChangesAsync(); } @@ -163,7 +171,13 @@ namespace Contextlib public async Task RemoveCommentary(int id) { - _repo.Delete(id); + + Commentary? commentary = await GetCommentaryById(id); + if (commentary == null) + { + throw new KeyNotFoundException($"Error : No comment found with the ID: {id}."); + } + _repo.Delete(commentary); await _context.SaveChangesAsync(); } diff --git a/WF_EF_Api/Contextlib/DbSourceManager.cs b/WF_EF_Api/Contextlib/DbSourceManager.cs index 6f470f7..e2ed299 100644 --- a/WF_EF_Api/Contextlib/DbSourceManager.cs +++ b/WF_EF_Api/Contextlib/DbSourceManager.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Entity; using Shared; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace Contextlib { @@ -40,6 +41,12 @@ namespace Contextlib throw new NotImplementedException(); } + public async Task> GetSomesSource(int page, int count) + { + var srcLst = _repo.GetItems(page, count, []).ToList(); + return new PaginationResult(srcLst.Count, 0, srcLst.Count, srcLst); + } + public async Task> GetSourceByDate(int date) { diff --git a/WF_EF_Api/Contextlib/WTFContext.cs b/WF_EF_Api/Contextlib/WTFContext.cs index 1a765f7..af9c12a 100644 --- a/WF_EF_Api/Contextlib/WTFContext.cs +++ b/WF_EF_Api/Contextlib/WTFContext.cs @@ -53,7 +53,7 @@ namespace Contextlib .HasMany() .WithMany() .UsingEntity( - i => i.HasKey(e => new { e.IdUser, e.IdQuote }) + i => i.HasKey(e => e.Id) ); modelBuilder.Entity() diff --git a/WF_EF_Api/Dto2Entities/Extention.cs b/WF_EF_Api/Dto2Entities/Extention.cs index a453875..fcd8407 100644 --- a/WF_EF_Api/Dto2Entities/Extention.cs +++ b/WF_EF_Api/Dto2Entities/Extention.cs @@ -282,7 +282,9 @@ namespace Dto2Entities commentary.Id = item.Id; commentary.DateCommentary = item.Date; commentary.Comment = item.Comment; + commentary.User = new Users(); commentary.User.UserName = item.User; + commentary.User.Images = new Images(); commentary.User.Images.ImgPath = item.ImagePath; return commentary; } diff --git a/WF_EF_Api/ServicesApi/CommentaryService.cs b/WF_EF_Api/ServicesApi/CommentaryService.cs index e151c03..4758ba6 100644 --- a/WF_EF_Api/ServicesApi/CommentaryService.cs +++ b/WF_EF_Api/ServicesApi/CommentaryService.cs @@ -42,7 +42,14 @@ namespace ServicesApi public async Task GetCommentaryById(int id) { - return commentaryService.GetCommentaryById(id).Result.ToDto(); + try + { + return (await commentaryService.GetCommentaryById(id)).ToDto(); + } + catch(KeyNotFoundException) + { + throw new KeyNotFoundException($"No comments found with the given ID: {id}."); + } } public async Task> GetCommentaryByQuote(int quoteId, int index, int pageSize) diff --git a/WF_EF_Api/ServicesApi/SourceService.cs b/WF_EF_Api/ServicesApi/SourceService.cs index 4a7c8fc..acefbcc 100644 --- a/WF_EF_Api/ServicesApi/SourceService.cs +++ b/WF_EF_Api/ServicesApi/SourceService.cs @@ -36,16 +36,21 @@ namespace ServicesApi return await srcService.GetLastSourceId(); } + public async Task> GetSomesSource(int page, int count) + { + var sources = (await srcService.GetSomesSource(page, count)).items; + return new PaginationResult(sources.Count(), page, count, sources.ToDto()); + } + public async Task> GetSourceByDate(int date) { - var sources = ( await srcService.GetSourceByDate(date)).items; + var sources = (await srcService.GetSourceByDate(date)).items; return new PaginationResult(sources.Count(), 0, 10, sources.ToDto()); - } public async Task GetSourceById(int id) { - return srcService.GetSourceById(id).Result.ToDto(); + return (await srcService.GetSourceById(id)).ToDto(); } public async Task GetSourceByTitle(string title) diff --git a/WF_EF_Api/Shared/ISourceService.cs b/WF_EF_Api/Shared/ISourceService.cs index 9657db7..73fd2c6 100644 --- a/WF_EF_Api/Shared/ISourceService.cs +++ b/WF_EF_Api/Shared/ISourceService.cs @@ -42,5 +42,7 @@ namespace Shared // Retrieves the unique identifier of the last added source. Task GetLastSourceId(); + + Task> GetSomesSource(int page, int count); } } diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250317163102_migrationTest1.Designer.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250317163102_migrationTest1.Designer.cs deleted file mode 100644 index e352e28..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250317163102_migrationTest1.Designer.cs +++ /dev/null @@ -1,1065 +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("20250317163102_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("IdUser") - .HasColumnType("int"); - - b.Property("IdQuote") - .HasColumnType("int"); - - b.Property("Comment") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("DateCommentary") - .HasColumnType("date") - .HasColumnName("DateCommentary"); - - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.HasKey("IdUser", "IdQuote"); - - b.HasIndex("IdQuote"); - - b.ToTable("comments"); - - b.HasData( - new - { - IdUser = 2, - IdQuote = 1, - Comment = "Ce film est le meilleur", - DateCommentary = new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = 1 - }, - new - { - IdUser = 3, - IdQuote = 1, - Comment = "Very good", - DateCommentary = new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = 2 - }); - }); - - 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(100) - .HasColumnType("nvarchar(100)"); - - 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(100) - .HasColumnType("nvarchar(100)"); - - 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("Commentarys") - .HasForeignKey("IdQuote") - .OnDelete(DeleteBehavior.ClientCascade) - .IsRequired(); - - b.HasOne("Entity.Users", "User") - .WithMany() - .HasForeignKey("IdUser") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Quote"); - - b.Navigation("User"); - }); - - 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.ClientCascade) - .IsRequired(); - - b.HasOne("Entity.Users", "Users") - .WithMany() - .HasForeignKey("IdUsers") - .OnDelete(DeleteBehavior.ClientCascade) - .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"); - - 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("Commentarys"); - - b.Navigation("DailyQuotes"); - }); - - modelBuilder.Entity("Entity.Source", b => - { - b.Navigation("Quotes"); - }); - - modelBuilder.Entity("Entity.Users", b => - { - b.Navigation("Quotes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250318135625_migr1.Designer.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250318135625_migr1.Designer.cs deleted file mode 100644 index 2ba04f3..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250318135625_migr1.Designer.cs +++ /dev/null @@ -1,1065 +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("20250318135625_migr1")] - partial class migr1 - { - /// - 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("IdUser") - .HasColumnType("int"); - - b.Property("IdQuote") - .HasColumnType("int"); - - b.Property("Comment") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("DateCommentary") - .HasColumnType("date") - .HasColumnName("DateCommentary"); - - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.HasKey("IdUser", "IdQuote"); - - b.HasIndex("IdQuote"); - - b.ToTable("comments"); - - b.HasData( - new - { - IdUser = 2, - IdQuote = 1, - Comment = "Ce film est le meilleur", - DateCommentary = new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = 1 - }, - new - { - IdUser = 3, - IdQuote = 1, - Comment = "Very good", - DateCommentary = new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = 2 - }); - }); - - 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(100) - .HasColumnType("nvarchar(100)"); - - 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(100) - .HasColumnType("nvarchar(100)"); - - 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("Commentarys") - .HasForeignKey("IdQuote") - .OnDelete(DeleteBehavior.ClientCascade) - .IsRequired(); - - b.HasOne("Entity.Users", "User") - .WithMany() - .HasForeignKey("IdUser") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Quote"); - - b.Navigation("User"); - }); - - 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.ClientCascade) - .IsRequired(); - - b.HasOne("Entity.Users", "Users") - .WithMany() - .HasForeignKey("IdUsers") - .OnDelete(DeleteBehavior.ClientCascade) - .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"); - - 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("Commentarys"); - - b.Navigation("DailyQuotes"); - }); - - modelBuilder.Entity("Entity.Source", b => - { - b.Navigation("Quotes"); - }); - - modelBuilder.Entity("Entity.Users", b => - { - b.Navigation("Quotes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250318135625_migr1.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250318135625_migr1.cs deleted file mode 100644 index 00b10fb..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250318135625_migr1.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace StubbedContextLib.Migrations -{ - /// - public partial class migr1 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250328102709_migr5.Designer.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250328102709_migr5.Designer.cs deleted file mode 100644 index 7e637c8..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250328102709_migr5.Designer.cs +++ /dev/null @@ -1,1107 +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("20250328102709_migr5")] - partial class migr5 - { - /// - 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.Admin", b => - { - b.Property("IdUsers") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("IdUsers")); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("IdUsers"); - - b.HasIndex("UserId"); - - b.ToTable("admins"); - }); - - 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("IdUser") - .HasColumnType("int"); - - b.Property("IdQuote") - .HasColumnType("int"); - - b.Property("Comment") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("DateCommentary") - .HasColumnType("date") - .HasColumnName("DateCommentary"); - - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.HasKey("IdUser", "IdQuote"); - - b.HasIndex("IdQuote"); - - b.ToTable("comments"); - - b.HasData( - new - { - IdUser = 2, - IdQuote = 1, - Comment = "Ce film est le meilleur", - DateCommentary = new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = 1 - }, - new - { - IdUser = 3, - IdQuote = 1, - Comment = "Very good", - DateCommentary = new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = 2 - }); - }); - - 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("IsValid") - .HasColumnType("bit"); - - 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", - IsValid = true, - Text = "Qui est le leader de la Communauté de l'Anneau ?" - }, - new - { - Id = 2, - AnswerA = "Serdaigle", - AnswerB = "Gryffondor", - AnswerC = "Serpentard", - AnswerD = "Poufsouffle", - CorrectAnswer = "B", - IsValid = false, - Text = "Dans quelle maison Harry Potter est-il ?" - }, - new - { - Id = 3, - AnswerA = "Saroumane", - AnswerB = "Sauron", - AnswerC = "Gollum", - AnswerD = "Gothmog", - CorrectAnswer = "B", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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(100) - .HasColumnType("nvarchar(100)"); - - 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(100) - .HasColumnType("nvarchar(100)"); - - 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.Admin", b => - { - b.HasOne("Entity.Users", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - 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("Commentarys") - .HasForeignKey("IdQuote") - .OnDelete(DeleteBehavior.ClientCascade) - .IsRequired(); - - b.HasOne("Entity.Users", "User") - .WithMany() - .HasForeignKey("IdUser") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Quote"); - - b.Navigation("User"); - }); - - 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.ClientCascade) - .IsRequired(); - - b.HasOne("Entity.Users", "Users") - .WithMany() - .HasForeignKey("IdUsers") - .OnDelete(DeleteBehavior.ClientCascade) - .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"); - - 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("Commentarys"); - - b.Navigation("DailyQuotes"); - }); - - modelBuilder.Entity("Entity.Source", b => - { - b.Navigation("Quotes"); - }); - - modelBuilder.Entity("Entity.Users", b => - { - b.Navigation("Quotes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250328102709_migr5.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250328102709_migr5.cs deleted file mode 100644 index 28c1b1d..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250328102709_migr5.cs +++ /dev/null @@ -1,126 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace StubbedContextLib.Migrations -{ - /// - public partial class migr5 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "IsValid", - table: "question", - type: "bit", - nullable: false, - defaultValue: false); - - migrationBuilder.CreateTable( - name: "admins", - columns: table => new - { - IdUsers = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - UserId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_admins", x => x.IdUsers); - table.ForeignKey( - name: "FK_admins_users_UserId", - column: x => x.UserId, - principalTable: "users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.UpdateData( - table: "question", - keyColumn: "Id", - keyValue: 1, - column: "IsValid", - value: true); - - migrationBuilder.UpdateData( - table: "question", - keyColumn: "Id", - keyValue: 2, - column: "IsValid", - value: false); - - migrationBuilder.UpdateData( - table: "question", - keyColumn: "Id", - keyValue: 3, - column: "IsValid", - value: true); - - migrationBuilder.UpdateData( - table: "question", - keyColumn: "Id", - keyValue: 4, - column: "IsValid", - value: true); - - migrationBuilder.UpdateData( - table: "question", - keyColumn: "Id", - keyValue: 5, - column: "IsValid", - value: true); - - migrationBuilder.UpdateData( - table: "question", - keyColumn: "Id", - keyValue: 6, - column: "IsValid", - value: true); - - migrationBuilder.UpdateData( - table: "question", - keyColumn: "Id", - keyValue: 7, - column: "IsValid", - value: true); - - migrationBuilder.UpdateData( - table: "question", - keyColumn: "Id", - keyValue: 8, - column: "IsValid", - value: true); - - migrationBuilder.UpdateData( - table: "question", - keyColumn: "Id", - keyValue: 9, - column: "IsValid", - value: true); - - migrationBuilder.UpdateData( - table: "question", - keyColumn: "Id", - keyValue: 10, - column: "IsValid", - value: true); - - migrationBuilder.CreateIndex( - name: "IX_admins_UserId", - table: "admins", - column: "UserId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "admins"); - - migrationBuilder.DropColumn( - name: "IsValid", - table: "question"); - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250401141906_suprDailyQuote.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250401141906_suprDailyQuote.cs deleted file mode 100644 index 1f3b252..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250401141906_suprDailyQuote.cs +++ /dev/null @@ -1,61 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace StubbedContextLib.Migrations -{ - /// - public partial class suprDailyQuote : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "dailyquotes"); - - migrationBuilder.UpdateData( - table: "quotes", - keyColumn: "Id", - keyValue: 10, - column: "IsValid", - value: false); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - 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.InsertData( - table: "dailyquotes", - column: "IdQuote", - values: new object[] - { - 1, - 5 - }); - - migrationBuilder.UpdateData( - table: "quotes", - keyColumn: "Id", - keyValue: 10, - column: "IsValid", - value: true); - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250401143030_myFirstMigration.Designer.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250401143030_myFirstMigration.Designer.cs deleted file mode 100644 index de2bfe4..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250401143030_myFirstMigration.Designer.cs +++ /dev/null @@ -1,1107 +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("20250401143030_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.Admin", b => - { - b.Property("IdUsers") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("IdUsers")); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("IdUsers"); - - b.HasIndex("UserId"); - - b.ToTable("admins"); - }); - - 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("IdUser") - .HasColumnType("int"); - - b.Property("IdQuote") - .HasColumnType("int"); - - b.Property("Comment") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("DateCommentary") - .HasColumnType("date") - .HasColumnName("DateCommentary"); - - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.HasKey("IdUser", "IdQuote"); - - b.HasIndex("IdQuote"); - - b.ToTable("comments"); - - b.HasData( - new - { - IdUser = 2, - IdQuote = 1, - Comment = "Ce film est le meilleur", - DateCommentary = new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = 1 - }, - new - { - IdUser = 3, - IdQuote = 1, - Comment = "Very good", - DateCommentary = new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = 2 - }); - }); - - 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("IsValid") - .HasColumnType("bit"); - - 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", - IsValid = true, - Text = "Qui est le leader de la Communauté de l'Anneau ?" - }, - new - { - Id = 2, - AnswerA = "Serdaigle", - AnswerB = "Gryffondor", - AnswerC = "Serpentard", - AnswerD = "Poufsouffle", - CorrectAnswer = "B", - IsValid = false, - Text = "Dans quelle maison Harry Potter est-il ?" - }, - new - { - Id = 3, - AnswerA = "Saroumane", - AnswerB = "Sauron", - AnswerC = "Gollum", - AnswerD = "Gothmog", - CorrectAnswer = "B", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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(100) - .HasColumnType("nvarchar(100)"); - - 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 = false, - 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(100) - .HasColumnType("nvarchar(100)"); - - 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.Admin", b => - { - b.HasOne("Entity.Users", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - 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("Commentarys") - .HasForeignKey("IdQuote") - .OnDelete(DeleteBehavior.ClientCascade) - .IsRequired(); - - b.HasOne("Entity.Users", "User") - .WithMany() - .HasForeignKey("IdUser") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Quote"); - - b.Navigation("User"); - }); - - 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.ClientCascade) - .IsRequired(); - - b.HasOne("Entity.Users", "Users") - .WithMany() - .HasForeignKey("IdUsers") - .OnDelete(DeleteBehavior.ClientCascade) - .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"); - - 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("Commentarys"); - - b.Navigation("DailyQuotes"); - }); - - modelBuilder.Entity("Entity.Source", b => - { - b.Navigation("Quotes"); - }); - - modelBuilder.Entity("Entity.Users", b => - { - b.Navigation("Quotes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250401143030_myFirstMigration.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250401143030_myFirstMigration.cs deleted file mode 100644 index 78898b5..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250401143030_myFirstMigration.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace StubbedContextLib.Migrations -{ - /// - public partial class myFirstMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.UpdateData( - table: "quotes", - keyColumn: "Id", - keyValue: 10, - column: "IsValid", - value: false); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.UpdateData( - table: "quotes", - keyColumn: "Id", - keyValue: 10, - column: "IsValid", - value: true); - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250402084447_migration2-04.Designer.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250402084447_migration2-04.Designer.cs deleted file mode 100644 index 1ecdc86..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250402084447_migration2-04.Designer.cs +++ /dev/null @@ -1,1074 +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("20250402084447_migration2-04")] - partial class migration204 - { - /// - 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.Admin", b => - { - b.Property("IdUsers") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("IdUsers")); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("IdUsers"); - - b.HasIndex("UserId"); - - b.ToTable("admins"); - }); - - 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("IdUser") - .HasColumnType("int"); - - b.Property("IdQuote") - .HasColumnType("int"); - - b.Property("Comment") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("DateCommentary") - .HasColumnType("date") - .HasColumnName("DateCommentary"); - - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.HasKey("IdUser", "IdQuote"); - - b.HasIndex("IdQuote"); - - b.ToTable("comments"); - - b.HasData( - new - { - IdUser = 2, - IdQuote = 1, - Comment = "Ce film est le meilleur", - DateCommentary = new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = 1 - }, - new - { - IdUser = 3, - IdQuote = 1, - Comment = "Very good", - DateCommentary = new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = 2 - }); - }); - - 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("IsValid") - .HasColumnType("bit"); - - 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", - IsValid = true, - Text = "Qui est le leader de la Communauté de l'Anneau ?" - }, - new - { - Id = 2, - AnswerA = "Serdaigle", - AnswerB = "Gryffondor", - AnswerC = "Serpentard", - AnswerD = "Poufsouffle", - CorrectAnswer = "B", - IsValid = false, - Text = "Dans quelle maison Harry Potter est-il ?" - }, - new - { - Id = 3, - AnswerA = "Saroumane", - AnswerB = "Sauron", - AnswerC = "Gollum", - AnswerD = "Gothmog", - CorrectAnswer = "B", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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", - IsValid = true, - 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(100) - .HasColumnType("nvarchar(100)"); - - 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 = false, - 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(100) - .HasColumnType("nvarchar(100)"); - - 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.Admin", b => - { - b.HasOne("Entity.Users", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - 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("Commentarys") - .HasForeignKey("IdQuote") - .OnDelete(DeleteBehavior.ClientCascade) - .IsRequired(); - - b.HasOne("Entity.Users", "User") - .WithMany() - .HasForeignKey("IdUser") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Quote"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Entity.Favorite", b => - { - b.HasOne("Entity.Quote", "Quote") - .WithMany() - .HasForeignKey("IdQuote") - .OnDelete(DeleteBehavior.ClientCascade) - .IsRequired(); - - b.HasOne("Entity.Users", "Users") - .WithMany() - .HasForeignKey("IdUsers") - .OnDelete(DeleteBehavior.ClientCascade) - .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"); - - 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("Commentarys"); - }); - - modelBuilder.Entity("Entity.Source", b => - { - b.Navigation("Quotes"); - }); - - modelBuilder.Entity("Entity.Users", b => - { - b.Navigation("Quotes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250402084447_migration2-04.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250402084447_migration2-04.cs deleted file mode 100644 index 4f1a548..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250402084447_migration2-04.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace StubbedContextLib.Migrations -{ - /// - public partial class migration204 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250402105029_migration1.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250402105029_migration1.cs deleted file mode 100644 index 8e69aba..0000000 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250402105029_migration1.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace StubbedContextLib.Migrations -{ - /// - public partial class migration1 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250402105029_migration1.Designer.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250402113707_pm_api.Designer.cs similarity index 97% rename from WF_EF_Api/StubbedContextLib/Migrations/20250402105029_migration1.Designer.cs rename to WF_EF_Api/StubbedContextLib/Migrations/20250402113707_pm_api.Designer.cs index ca444d0..c1cc023 100644 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250402105029_migration1.Designer.cs +++ b/WF_EF_Api/StubbedContextLib/Migrations/20250402113707_pm_api.Designer.cs @@ -12,8 +12,8 @@ using StubbedContextLib; namespace StubbedContextLib.Migrations { [DbContext(typeof(StubWTFContext))] - [Migration("20250402105029_migration1")] - partial class migration1 + [Migration("20250402113707_pm_api")] + partial class pm_api { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250317163102_migrationTest1.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250402113707_pm_api.cs similarity index 90% rename from WF_EF_Api/StubbedContextLib/Migrations/20250317163102_migrationTest1.cs rename to WF_EF_Api/StubbedContextLib/Migrations/20250402113707_pm_api.cs index 437370b..f9dd7c8 100644 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250317163102_migrationTest1.cs +++ b/WF_EF_Api/StubbedContextLib/Migrations/20250402113707_pm_api.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace StubbedContextLib.Migrations { /// - public partial class migrationTest1 : Migration + public partial class pm_api : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -37,7 +37,8 @@ namespace StubbedContextLib.Migrations 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) + CorrectAnswer = table.Column(type: "nvarchar(1)", maxLength: 1, nullable: false), + IsValid = table.Column(type: "bit", nullable: false) }, constraints: table => { @@ -147,6 +148,25 @@ namespace StubbedContextLib.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "admins", + columns: table => new + { + IdUsers = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_admins", x => x.IdUsers); + table.ForeignKey( + name: "FK_admins_users_UserId", + column: x => x.UserId, + principalTable: "users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "quotes", columns: table => new @@ -210,23 +230,6 @@ namespace StubbedContextLib.Migrations 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 @@ -268,19 +271,19 @@ namespace StubbedContextLib.Migrations migrationBuilder.InsertData( table: "question", - columns: new[] { "Id", "AnswerA", "AnswerB", "AnswerC", "AnswerD", "CorrectAnswer", "Text" }, + columns: new[] { "Id", "AnswerA", "AnswerB", "AnswerC", "AnswerD", "CorrectAnswer", "IsValid", "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 ?" } + { 1, "Gimli", "Aragorn", "Frodon", "Gandalf", "B", true, "Qui est le leader de la Communauté de l'Anneau ?" }, + { 2, "Serdaigle", "Gryffondor", "Serpentard", "Poufsouffle", "B", false, "Dans quelle maison Harry Potter est-il ?" }, + { 3, "Saroumane", "Sauron", "Gollum", "Gothmog", "B", true, "Qui est le Seigneur des Ténèbres dans la saga Le Seigneur des Anneaux ?" }, + { 4, "Han Solo", "Princesse Leia", "Chewbacca", "R2-D2", "A", true, "Dans le film Star Wars : Episode IV, qui sauve Luke Skywalker de l'Étoile de la Mort ?" }, + { 5, "Reine Jadis", "Aslan", "Edmund", "Lucy", "B", true, "Qui est le souverain de Narnia dans Le Lion, la Sorcière Blanche et l'Armoire Magique ?" }, + { 6, "Smaug", "Falkor", "Norbert", "Shenron", "A", true, "Quel est le nom du dragon dans Le Hobbit ?" }, + { 7, "Bella Swan", "Edward Cullen", "Jacob Black", "Victoria", "A", true, "Qui est la première personne à être mordue par un vampire dans Twilight ?" }, + { 8, "Obi-Wan Kenobi", "Yoda", "Han Solo", "Luke Skywalker", "A", true, "Quel personnage dit Que la Force soit avec toi dans Star Wars ?" }, + { 9, "Dr. Ellie Sattler", "Alan Grant", "John Hammond", "Dennis Nedry", "B", true, "Dans Jurassic Park, quel est le nom du paléontologue sur l'île ?" }, + { 10, "Cersei Lannister", "Arya Stark", "Daenerys Targaryen", "Sansa Stark", "C", true, "Dans Game of Thrones, qui est surnommée la Mère des Dragons ?" } }); migrationBuilder.InsertData( @@ -369,7 +372,7 @@ namespace StubbedContextLib.Migrations { 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 } + { 10, "La quoi ?", 10, 4, 1, false, 1, 11025 } }); migrationBuilder.InsertData( @@ -381,15 +384,6 @@ namespace StubbedContextLib.Migrations { 1, 3, "Very good", new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), 2 } }); - migrationBuilder.InsertData( - table: "dailyquotes", - column: "IdQuote", - values: new object[] - { - 1, - 5 - }); - migrationBuilder.InsertData( table: "favorites", columns: new[] { "IdQuote", "IdUsers" }, @@ -406,6 +400,11 @@ namespace StubbedContextLib.Migrations { 10, 5 } }); + migrationBuilder.CreateIndex( + name: "IX_admins_UserId", + table: "admins", + column: "UserId"); + migrationBuilder.CreateIndex( name: "IX_characters_IdImage", table: "characters", @@ -456,10 +455,10 @@ namespace StubbedContextLib.Migrations protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( - name: "comments"); + name: "admins"); migrationBuilder.DropTable( - name: "dailyquotes"); + name: "comments"); migrationBuilder.DropTable( name: "favorites"); diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250401141906_suprDailyQuote.Designer.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250402134601_pm_apiV2.Designer.cs similarity index 96% rename from WF_EF_Api/StubbedContextLib/Migrations/20250401141906_suprDailyQuote.Designer.cs rename to WF_EF_Api/StubbedContextLib/Migrations/20250402134601_pm_apiV2.Designer.cs index 89c0f87..efad120 100644 --- a/WF_EF_Api/StubbedContextLib/Migrations/20250401141906_suprDailyQuote.Designer.cs +++ b/WF_EF_Api/StubbedContextLib/Migrations/20250402134601_pm_apiV2.Designer.cs @@ -12,8 +12,8 @@ using StubbedContextLib; namespace StubbedContextLib.Migrations { [DbContext(typeof(StubWTFContext))] - [Migration("20250401141906_suprDailyQuote")] - partial class suprDailyQuote + [Migration("20250402134601_pm_apiV2")] + partial class pm_apiV2 { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -130,11 +130,11 @@ namespace StubbedContextLib.Migrations modelBuilder.Entity("Entity.Commentary", b => { - b.Property("IdUser") + b.Property("Id") + .ValueGeneratedOnAdd() .HasColumnType("int"); - b.Property("IdQuote") - .HasColumnType("int"); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("Comment") .IsRequired() @@ -145,34 +145,36 @@ namespace StubbedContextLib.Migrations .HasColumnType("date") .HasColumnName("DateCommentary"); - b.Property("Id") - .ValueGeneratedOnAdd() + b.Property("IdQuote") .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + b.Property("IdUser") + .HasColumnType("int"); - b.HasKey("IdUser", "IdQuote"); + b.HasKey("Id"); b.HasIndex("IdQuote"); + b.HasIndex("IdUser"); + b.ToTable("comments"); b.HasData( new { - IdUser = 2, - IdQuote = 1, + Id = 1, Comment = "Ce film est le meilleur", DateCommentary = new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = 1 + IdQuote = 1, + IdUser = 2 }, new { - IdUser = 3, - IdQuote = 1, + Id = 2, Comment = "Very good", DateCommentary = new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), - Id = 2 + IdQuote = 1, + IdUser = 3 }); }); diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250402134601_pm_apiV2.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250402134601_pm_apiV2.cs new file mode 100644 index 0000000..ec12b89 --- /dev/null +++ b/WF_EF_Api/StubbedContextLib/Migrations/20250402134601_pm_apiV2.cs @@ -0,0 +1,86 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace StubbedContextLib.Migrations +{ + /// + public partial class pm_apiV2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_comments", + table: "comments"); + + migrationBuilder.DeleteData( + table: "comments", + keyColumns: new[] { "IdQuote", "IdUser" }, + keyValues: new object[] { 1, 2 }); + + migrationBuilder.DeleteData( + table: "comments", + keyColumns: new[] { "IdQuote", "IdUser" }, + keyValues: new object[] { 1, 3 }); + + migrationBuilder.AddPrimaryKey( + name: "PK_comments", + table: "comments", + column: "Id"); + + migrationBuilder.InsertData( + table: "comments", + columns: new[] { "Id", "Comment", "DateCommentary", "IdQuote", "IdUser" }, + 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.CreateIndex( + name: "IX_comments_IdUser", + table: "comments", + column: "IdUser"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_comments", + table: "comments"); + + migrationBuilder.DropIndex( + name: "IX_comments_IdUser", + table: "comments"); + + migrationBuilder.DeleteData( + table: "comments", + keyColumn: "Id", + keyValue: 1); + + migrationBuilder.DeleteData( + table: "comments", + keyColumn: "Id", + keyValue: 2); + + migrationBuilder.AddPrimaryKey( + name: "PK_comments", + table: "comments", + columns: new[] { "IdUser", "IdQuote" }); + + migrationBuilder.InsertData( + table: "comments", + columns: new[] { "IdQuote", "IdUser", "Comment", "DateCommentary", "Id" }, + values: new object[,] + { + { 1, 2, "Ce film est le meilleur", new DateTime(2025, 2, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), 1 }, + { 1, 3, "Very good", new DateTime(2025, 3, 11, 0, 0, 0, 0, DateTimeKind.Unspecified), 2 } + }); + } + } +} diff --git a/WF_EF_Api/StubbedContextLib/StubbedContextLib.csproj b/WF_EF_Api/StubbedContextLib/StubbedContextLib.csproj index 9a838f3..4ae6e1b 100644 --- a/WF_EF_Api/StubbedContextLib/StubbedContextLib.csproj +++ b/WF_EF_Api/StubbedContextLib/StubbedContextLib.csproj @@ -18,4 +18,8 @@ + + + + diff --git a/WF_EF_Api/WfApi/Controllers/CommentariesController.cs b/WF_EF_Api/WfApi/Controllers/CommentariesController.cs index cdeb881..7fd26bc 100644 --- a/WF_EF_Api/WfApi/Controllers/CommentariesController.cs +++ b/WF_EF_Api/WfApi/Controllers/CommentariesController.cs @@ -57,15 +57,17 @@ namespace WfApi.Controllers return BadRequest(new { message = "Comment data is required." }); } - var existingCommentary = _commentary.GetCommentaryById(newCommentary.Id).Result; - if (existingCommentary != null) + try { + var existingCommentary = await _commentary.GetCommentaryById(newCommentary.Id); return Conflict(new { message = "A comment with this ID already exists." }); } + catch (KeyNotFoundException e) + { + await _commentary.AddComment(newCommentary, idQuote); - await _commentary.AddComment(newCommentary, idQuote); - - return CreatedAtAction(nameof(GetCommentary), new { id = newCommentary.Id }, newCommentary); + return CreatedAtAction(nameof(GetCommentary), new { id = newCommentary.Id }, newCommentary); + } } catch (Exception) { @@ -89,7 +91,7 @@ namespace WfApi.Controllers return NotFound(new { message = "Commentary not found." }); } - _commentary.RemoveCommentary(existingCommentary.Id); + await _commentary.RemoveCommentary(existingCommentary.Id); return Ok(new { message = $"Commentary {id} deleted successfully." }); } diff --git a/WF_EF_Api/WfApi/Controllers/QuotesController.cs b/WF_EF_Api/WfApi/Controllers/QuotesController.cs index a43866b..ddcdb79 100644 --- a/WF_EF_Api/WfApi/Controllers/QuotesController.cs +++ b/WF_EF_Api/WfApi/Controllers/QuotesController.cs @@ -33,13 +33,9 @@ namespace WfApi.Controllers try { var result = await _quote.GetQuoteById(id); - if (result == null) - { - throw new KeyNotFoundException($"Error : No quotes found with the ID: {id}."); - } if (result!=null) { - return await Task.FromResult(Ok(result)); + return Ok(result); } else { diff --git a/WF_EF_Api/WfApi/Controllers/SourceController.cs b/WF_EF_Api/WfApi/Controllers/SourceController.cs new file mode 100644 index 0000000..744a737 --- /dev/null +++ b/WF_EF_Api/WfApi/Controllers/SourceController.cs @@ -0,0 +1,125 @@ +using System.Net; +using DTO; +using Entity; +using Microsoft.AspNetCore.Mvc; +using Shared; + +namespace WfApi.Controllers +{ + [Route("api/v1/source")] + [ApiController] + public class SourceController : ControllerBase + { + private readonly ISourceService _source; + + private readonly ILogger _logger; + public SourceController(ISourceService sourceService, ILogger logger) + { + _source = sourceService; + _logger = logger; + + } + + [HttpGet("{id}")] // Indiquer que l'id est dans l'URL + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task GetSource(int id) + { + try + { + var source = await _source.GetSourceById(id); + if(source != null) + { + return Ok(source); + } + else + { + return NoContent(); + } + } + catch(Exception e) + { + return StatusCode((int)HttpStatusCode.InternalServerError, new { message = "Internal Server Error (" + e + ")" }); + } + } + + [HttpGet("all")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task GetAllSource(int index = 0, int count = 10) + { + try + { + var result = await _source.GetSomesSource(index, count); + + if (result != null) + { + return await Task.FromResult(Ok(result)); + } + else + { + return NoContent(); + } + } + catch (Exception e) + { + return StatusCode((int)HttpStatusCode.InternalServerError, new { message = "Internal Server Error (" + e + ")" }); + } + } + + [HttpPost] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + public async Task CreateSource([FromBody] SourceDTO newSource) + { + try + { + if(newSource == null) + { + return BadRequest(new { message = "Source data is required." }); + } + try + { + var existingSource = await _source.GetSourceById(newSource.Id); + return Conflict(new { message = "A source with this ID already exists." }); + } + catch(KeyNotFoundException e) + { + await _source.AddSource(newSource); + return CreatedAtAction(nameof(GetAllSource), new { id = newSource.Id }, newSource); + } + } + catch (Exception e) + { + return StatusCode((int)HttpStatusCode.InternalServerError, new { message = "Internal Server Error (" + e + ")" }); + } + } + + [HttpPut()] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task UpdateSource([FromQuery] int id, [FromBody] SourceDTO updatedSource) + { + try + { + if (updatedSource == null) + { + return BadRequest(new { message = "new source data is required." }); + } + + var result = _source.UpdateSource(id, updatedSource); + + return Ok(result); + } + catch (Exception e) + { + return StatusCode((int)HttpStatusCode.InternalServerError, new { message = "Internal Server Error (" + e + ")" }); + } + } + } +} diff --git a/WF_EF_Api/XUnitTest/ApiUnitTest.cs b/WF_EF_Api/XUnitTest/ApiUnitTest.cs index 7591909..8692e14 100644 --- a/WF_EF_Api/XUnitTest/ApiUnitTest.cs +++ b/WF_EF_Api/XUnitTest/ApiUnitTest.cs @@ -11,272 +11,272 @@ namespace XUnitTest { public class UnitTest1 { - private readonly Mock> _mockUserService; - private readonly Mock> _mockLogger; - private readonly UsersController _userController; - - public UnitTest1() - { - // Initialisation des mocks - _mockUserService = new Mock>(); - _mockLogger = new Mock>(); - _userController = new UsersController(_mockUserService.Object, _mockLogger.Object); - } - - - - [Fact] - public async Task Get_ReturnsOk_WhenUserExists() - { - // Arrange - var userId = 1; - var userDTO = new UserDTO - { - Id = userId, - Pseudo = "test", - Email = "test@unitaire.fr", - ImageProfil = "http://test", - Password = "1234" - }; - - _mockUserService.Setup(service => service.GetUserById(userId)).ReturnsAsync(userDTO); - - // Act - var result = await _userController.Get(userId); - - // Assert - Assert.IsType(result); - } - - - - - [Fact] - public async Task GetAllUsers_ReturnsOk() - { - // Arrange - var userDTO = new UserDTO - { - Id = 1, - Pseudo = "test", - Email = "test@unitaire.fr", - ImageProfil = "http://test", - Password = "1234" - }; - var userDTO2 = new UserDTO - { - Id = 2, - Pseudo = "test", - Email = "test@unitaire.fr", - ImageProfil = "http://test", - Password = "1234" - }; - - _mockUserService.Setup(service => service.GetUserById(1)).ReturnsAsync(userDTO); - _mockUserService.Setup(service => service.GetUserById(2)).ReturnsAsync(userDTO); - - // Act - var result = await _userController.GetAllUsers(); - - // Assert - Assert.IsType(result); - } - - - - [Fact] - public async Task GetHashPassword_ReturnsOk_WhenPasswordHashIsFound() - { - // Arrange - var username = "testUser"; - var expectedHash = "hashedPassword"; - - var taskResult = Task.FromResult(expectedHash); - _mockUserService.Setup(service => service.GetHashPassword(username)).Returns(taskResult); - - // Act - var result = await _userController.GetHashPassword(username); - - // Assert - Assert.IsType(result); - } - - [Fact] - public async Task GetUserByUsername_ReturnsOk_WhenPasswordHashIsFound() - { - // Arrange - var username = "testUser"; - var userDTO = new UserDTO - { - Id = 1, - Pseudo = "testUser", - Email = "test@unitaire.fr", - ImageProfil = "http://test", - Password = "1234" - }; - - var taskResult = Task.FromResult(userDTO); - _mockUserService.Setup(service => service.GetUserByUsername(username)).Returns(taskResult); - - // Act - var result = await _userController.GetUserByUsername(username); - - // Assert - Assert.IsType(result); - } - - [Fact] - public async Task GetUserByEmail_ReturnsOk_WhenUserExists() - { - // Arrange - var email = "test@unitaire.fr"; - var userDTO = new UserDTO - { - Id = 1, - Pseudo = "testUser", - Email = email, - ImageProfil = "http://test", - Password = "1234" - }; + //private readonly Mock> _mockUserService; + //private readonly Mock> _mockLogger; + //private readonly UsersController _userController; + + //public UnitTest1() + //{ + // // Initialisation des mocks + // _mockUserService = new Mock>(); + // _mockLogger = new Mock>(); + // _userController = new UsersController(_mockUserService.Object, _mockLogger.Object); + //} + + + + //[Fact] + //public async Task Get_ReturnsOk_WhenUserExists() + //{ + // // Arrange + // var userId = 1; + // var userDTO = new UserDTO + // { + // Id = userId, + // Pseudo = "test", + // Email = "test@unitaire.fr", + // ImageProfil = "http://test", + // Password = "1234" + // }; + + // _mockUserService.Setup(service => service.GetUserById(userId)).ReturnsAsync(userDTO); + + // // Act + // var result = await _userController.Get(userId); + + // // Assert + // Assert.IsType(result); + //} + + + + + //[Fact] + //public async Task GetAllUsers_ReturnsOk() + //{ + // // Arrange + // var userDTO = new UserDTO + // { + // Id = 1, + // Pseudo = "test", + // Email = "test@unitaire.fr", + // ImageProfil = "http://test", + // Password = "1234" + // }; + // var userDTO2 = new UserDTO + // { + // Id = 2, + // Pseudo = "test", + // Email = "test@unitaire.fr", + // ImageProfil = "http://test", + // Password = "1234" + // }; + + // _mockUserService.Setup(service => service.GetUserById(1)).ReturnsAsync(userDTO); + // _mockUserService.Setup(service => service.GetUserById(2)).ReturnsAsync(userDTO); + + // // Act + // var result = await _userController.GetAllUsers(); + + // // Assert + // Assert.IsType(result); + //} + + + + //[Fact] + //public async Task GetHashPassword_ReturnsOk_WhenPasswordHashIsFound() + //{ + // // Arrange + // var username = "testUser"; + // var expectedHash = "hashedPassword"; + + // var taskResult = Task.FromResult(expectedHash); + // _mockUserService.Setup(service => service.GetHashPassword(username)).Returns(taskResult); + + // // Act + // var result = await _userController.GetHashPassword(username); + + // // Assert + // Assert.IsType(result); + //} + + //[Fact] + //public async Task GetUserByUsername_ReturnsOk_WhenPasswordHashIsFound() + //{ + // // Arrange + // var username = "testUser"; + // var userDTO = new UserDTO + // { + // Id = 1, + // Pseudo = "testUser", + // Email = "test@unitaire.fr", + // ImageProfil = "http://test", + // Password = "1234" + // }; + + // var taskResult = Task.FromResult(userDTO); + // _mockUserService.Setup(service => service.GetUserByUsername(username)).Returns(taskResult); + + // // Act + // var result = await _userController.GetUserByUsername(username); + + // // Assert + // Assert.IsType(result); + //} + + //[Fact] + //public async Task GetUserByEmail_ReturnsOk_WhenUserExists() + //{ + // // Arrange + // var email = "test@unitaire.fr"; + // var userDTO = new UserDTO + // { + // Id = 1, + // Pseudo = "testUser", + // Email = email, + // ImageProfil = "http://test", + // Password = "1234" + // }; - var taskResult = Task.FromResult(userDTO); - _mockUserService.Setup(service => service.GetUserByEmail(email)).Returns(taskResult); + // var taskResult = Task.FromResult(userDTO); + // _mockUserService.Setup(service => service.GetUserByEmail(email)).Returns(taskResult); - // Act - var result = await _userController.GetUserByEmail(email); + // // Act + // var result = await _userController.GetUserByEmail(email); - // Assert - Assert.IsType(result); - } + // // Assert + // Assert.IsType(result); + //} - [Fact] - public async Task GetCountUser_ReturnsOk_WhenCountIsSuccessful() - { - // Arrange - var expectedCount = 5; - var taskResult = Task.FromResult(expectedCount); + //[Fact] + //public async Task GetCountUser_ReturnsOk_WhenCountIsSuccessful() + //{ + // // Arrange + // var expectedCount = 5; + // var taskResult = Task.FromResult(expectedCount); - _mockUserService.Setup(service => service.CountUser()).Returns(taskResult); + // _mockUserService.Setup(service => service.CountUser()).Returns(taskResult); - // Act - var result = await _userController.GetCountUser(); + // // Act + // var result = await _userController.GetCountUser(); - // Assert - Assert.IsType(result); - } + // // Assert + // Assert.IsType(result); + //} - [Fact] - public async Task GetExistUsername_ReturnsOk_WhenUserExists() - { - // Arrange - var username = "testUser"; - var taskResult = Task.FromResult(true); + //[Fact] + //public async Task GetExistUsername_ReturnsOk_WhenUserExists() + //{ + // // Arrange + // var username = "testUser"; + // var taskResult = Task.FromResult(true); - _mockUserService.Setup(service => service.ExistUsername(username)).Returns(taskResult); + // _mockUserService.Setup(service => service.ExistUsername(username)).Returns(taskResult); - // Act - var result = await _userController.GetExistUsername(username); + // // Act + // var result = await _userController.GetExistUsername(username); - // Assert - Assert.IsType(result); + // // Assert + // Assert.IsType(result); - } + //} - [Fact] - public async Task GetExistEmail_ReturnsOk_WhenEmailExists() - { - // Arrange - var email = "test@unitaire.fr"; - var taskResult = Task.FromResult(true); + //[Fact] + //public async Task GetExistEmail_ReturnsOk_WhenEmailExists() + //{ + // // Arrange + // var email = "test@unitaire.fr"; + // var taskResult = Task.FromResult(true); - _mockUserService.Setup(service => service.ExistEmail(email)).Returns(taskResult); + // _mockUserService.Setup(service => service.ExistEmail(email)).Returns(taskResult); - // Act - var result = await _userController.GetExistEmail(email); + // // Act + // var result = await _userController.GetExistEmail(email); - // Assert - Assert.IsType(result); + // // Assert + // Assert.IsType(result); - } - [Fact] - public async Task UpdateUser_ReturnsOk_WhenUserDataIsValid() - { - // Arrange - var id = 1; - var updatedUser = new UserDTO - { - Id = id, - Pseudo = "UpdatedUser", - Email = "updated@unitaire.fr", - ImageProfil = "http://updatedImage.com", - Password = "newPassword123" - }; - - var taskResult = Task.FromResult(updatedUser); - - _mockUserService.Setup(service => service.UpdateUser(id, updatedUser)).Returns(taskResult); - - // Act - var result = await _userController.UpdateUser(id, updatedUser); - - // Assert - var okResult = Assert.IsType(result); - - Assert.IsType(result); - } - [Fact] - public async Task CreateUser_ReturnsCreatedAtAction_WhenUserIsValid() - { - // Arrange - var newUser = new UserDTO - { - Id = 2, - Pseudo = "NewUser", - Email = "newuser@unitaire.fr", - ImageProfil = "http://newuserimage.com", - Password = "newPassword123" - }; - - _mockUserService.Setup(service => service.GetUserById(newUser.Id)).ReturnsAsync((UserDTO)null); - - _mockUserService.Setup(service => service.AddUser(newUser)).Verifiable(); - - // Act - var result = await _userController.CreateUser(newUser); - - // Assert - var createdResult = Assert.IsType(result); - Assert.Equal(newUser.Id, createdResult.RouteValues["id"]); - } - - - [Fact] - public async Task DeletePlayer_ReturnsOk_WhenPlayerExists() - { - // Arrange - var id = 1; - var existingPlayer = new UserDTO - { - Id = id, - Pseudo = "ExistingUser", - Email = "existing@unitaire.fr", - ImageProfil = "http://existingimage.com", - Password = "existingPassword123" - }; - - _mockUserService.Setup(service => service.GetUserById(id)).ReturnsAsync(existingPlayer); - - _mockUserService.Setup(service => service.RemoveUser(existingPlayer.Id)).Verifiable(); - - // Act - var result = await _userController.DeletePlayer(id); - - // Assert - Assert.IsType(result); + //} + //[Fact] + //public async Task UpdateUser_ReturnsOk_WhenUserDataIsValid() + //{ + // // Arrange + // var id = 1; + // var updatedUser = new UserDTO + // { + // Id = id, + // Pseudo = "UpdatedUser", + // Email = "updated@unitaire.fr", + // ImageProfil = "http://updatedImage.com", + // Password = "newPassword123" + // }; + + // var taskResult = Task.FromResult(updatedUser); + + // _mockUserService.Setup(service => service.UpdateUser(id, updatedUser)).Returns(taskResult); + + // // Act + // var result = await _userController.UpdateUser(id, updatedUser); + + // // Assert + // var okResult = Assert.IsType(result); + + // Assert.IsType(result); + //} + //[Fact] + //public async Task CreateUser_ReturnsCreatedAtAction_WhenUserIsValid() + //{ + // // Arrange + // var newUser = new UserDTO + // { + // Id = 2, + // Pseudo = "NewUser", + // Email = "newuser@unitaire.fr", + // ImageProfil = "http://newuserimage.com", + // Password = "newPassword123" + // }; + + // _mockUserService.Setup(service => service.GetUserById(newUser.Id)).ReturnsAsync((UserDTO)null); + + // _mockUserService.Setup(service => service.AddUser(newUser)).Verifiable(); + + // // Act + // var result = await _userController.CreateUser(newUser); + + // // Assert + // var createdResult = Assert.IsType(result); + // Assert.Equal(newUser.Id, createdResult.RouteValues["id"]); + //} + + + //[Fact] + //public async Task DeletePlayer_ReturnsOk_WhenPlayerExists() + //{ + // // Arrange + // var id = 1; + // var existingPlayer = new UserDTO + // { + // Id = id, + // Pseudo = "ExistingUser", + // Email = "existing@unitaire.fr", + // ImageProfil = "http://existingimage.com", + // Password = "existingPassword123" + // }; + + // _mockUserService.Setup(service => service.GetUserById(id)).ReturnsAsync(existingPlayer); + + // _mockUserService.Setup(service => service.RemoveUser(existingPlayer.Id)).Verifiable(); + + // // Act + // var result = await _userController.DeletePlayer(id); + + // // Assert + // Assert.IsType(result); - } + //} }