diff --git a/README.md b/README.md
index 94b08a7..40e9d37 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,53 @@
# WF-PmAPI
+🟨 En cours / ✅ Fait / ❌ Pas fait
+
+### Critères Entity Framework
+
+niveau | description | coeff | jalon | État
+--- | --- | --- | --- | ---
+☢️ | Le dépôt doit être accessible par l'enseignant | ☢️ | J1 | ✅
+☢️ | un .gitignore doit exister au premier push | ☢️ | J1 | ✅
+🎬 | les *projets* et les tests compilent | 1 | J1 & J2 | ✅
+🎬 | le projet et le tests s'exécutent sans bug (concernant la partie persistance) | 3 | J1 & J2 | ✅
+🟢 | Transcription du modèle : Modèle vers entités (et inversement) | 2 | J1 | 🟨
+🟢 | Requêtes CRUD simples (sur une table) | 1 | J1 | 🟨
+🟢 | Utilisation de LINQ to Entities | 2 | J1 |
+🟡 | Injection / indépendance du fournisseur | 1 | J1 | ❌
+🟡 | Requêtes CRUD sur des données complexes (images par exemple) | 2 | J1 | 🟨
+🟢 | Tests - Appli Console | 1 | J1 | ❌
+🟢 | Tests - Tests unitaires (avec SQLite in memory) | 2 | J1 | ❌
+🟢 | Tests - Données stubbées et/ou Moq | 1 | J1 | ✅
+🟡 | CI : build, tests, Sonar (doc?) | 1 | J1 | ❌
+🟡 | Utilisation de relations (One-to-One, One-to-Many, Many-to-Many) (+ mapping, TU, Requêtes) | 4 | J1 | 🟨
+🟢 | Liens avec le web service | 2 | J1 | ❌
+🟡 | Utilisation d'un *Logger* | 1 | J1 | ❌
+🟡 | Déploiement | 4 | J2 | ❌
+🔴 | Unit of Work / Repository + extras (héritage, accès concurrents...) | 8 | J2 | ❌
+🟢 | Utilisation dans le projet | 2 | J2 | ❌
+🟢 | mon dépôt possède un readme qui apporte quelque chose... | 2 | J2 | ❌
+
+
+### Critères Web API
+
+niveau | description | coeff | jalon | État
+--- | --- | --- | --- | ---
+☢️ | Le dépôt doit être accessible par l'enseignant | ☢️ | J1 |
+☢️ | un .gitignore doit exister au premier push | ☢️ | J1 |
+🎬 | les *projets* et les tests compilent | 1 | J1 & J2 |
+🎬 | le projet et le tests s'exécutent sans bug (concernant la partie web api) | 4 | J1 & J2 |
+🟢 | Modèle <-> DTO | 1 | J1 |
+🟢 | Entities <-> DTO | 1 | J1 | 🟨
+🟡 | Authentification | 4 | J1 |
+🟢 | Requêtes GET, PUT, POST, DELETE sur des données simples (1 seul type d'objet en retour, propriétés de types natifs) | 2 | J1 |
+🟡 | Pagination & filtrage | 2 | J1 |
+🟢 | Injection de service | 2 | J1 |
+🟡 | Requêtes GET, PUT, POST, DELETE sur des données complexes (plusieurs données complexes en retour) | 4 | J1 |
+🟢 | Tests - Appli Console (consommation des requêtes) | 4 | J1 |
+🟢 | Tests - Tests unitaires (avec Stub et/ou Moq) | 2 | J1 |
+🟡 | CI : build, tests, Sonar, Documentation (en particulier Swagger avec exemples...) | 1 | J1 |
+🟢 | Liens avec la persistance en base de données | 4 | J1 |
+🟡 | Utilisation d'un *Logger* | 1 | J1 |
+🟡 | Déploiement | 4 | J2 |
+🟡 | Utilisation dans le projet | 4 | J2 |
+🎬 | mon dépôt possède un readme qui apporte quelque chose... | 1 | J2 |
\ No newline at end of file
diff --git a/WF_EF_Api/ConsoleTest/ConsoleTest.csproj b/WF_EF_Api/ConsoleTest/ConsoleTest.csproj
index 206b89a..9a4ee54 100644
--- a/WF_EF_Api/ConsoleTest/ConsoleTest.csproj
+++ b/WF_EF_Api/ConsoleTest/ConsoleTest.csproj
@@ -7,4 +7,12 @@
enable
+
+
+
+
+
+
+
+
diff --git a/WF_EF_Api/ConsoleTest/Program.cs b/WF_EF_Api/ConsoleTest/Program.cs
index 127ed44..7a36b87 100644
--- a/WF_EF_Api/ConsoleTest/Program.cs
+++ b/WF_EF_Api/ConsoleTest/Program.cs
@@ -1 +1,134 @@
-Console.WriteLine("bonjour");
\ No newline at end of file
+using Contextlib;
+using Entity;
+using Microsoft.Data.Sqlite;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Options;
+using StubbedContextLib;
+using static System.Net.Mime.MediaTypeNames;
+using static System.Net.WebRequestMethods;
+
+var connection = new SqliteConnection("DataSource=:memory:");
+connection.Open();
+var options = new DbContextOptionsBuilder()
+ .UseSqlite(connection)
+ .Options;
+
+using (var _context = new StubWTFContext(options))
+{
+ _context.Database.EnsureCreated();
+
+ // ---- Test Image ---- //
+
+ var imageManager = new DbImagesManager(_context);
+
+
+ await imageManager.AddImage(new Images() { Id = 11, ImgPath = "https://www.bing.com/ck/a?!&&p=390428c2820add92760900204667aa721b17d4eb9e8537c91544d76283d06b14JmltdHM9MTc0MjQyODgwMA&ptn=3&ver=2&hsh=4&fclid=297ef5ed-ac44-66f2-2498-e058adb06776&u=a1aHR0cHM6Ly93d3cucG9rZXBlZGlhLmZyL01hamFzcGlj&ntb=1" });
+ await imageManager.AddImage(new Images() { Id = 12, ImgPath = "https://www.bing.com/images/search?view=detailV2&ccid=t57OzeAT&id=1CCCBB65825E5FB93F10CA6D29EFDBBFEB5CDF27&thid=OIP.t57OzeATZKjBDDrzXqbc5gHaE7&mediaurl=https%3a%2f%2fimg-19.commentcamarche.net%2fP51ArxVXHJKsgdTzGDaqajlWJ3s%3d%2f1500x%2fsmart%2f7b5dd43e607643fea1a61960e3f66fc4%2fccmcms-commentcamarche%2f39481621.jpg&cdnurl=https%3a%2f%2fth.bing.com%2fth%2fid%2fR.b79ececde01364a8c10c3af35ea6dce6%3frik%3dJ99c67%252fb7yltyg%26pid%3dImgRaw%26r%3d0&exph=999&expw=1500&q=image&simid=608026907577902968&ck=0D54F216D075AD6E0ABC46B3AAB7E80A&selectedIndex=19&itb=0" });
+ Console.WriteLine("---- Test ajout image (id : 11, 12)");
+ var images = await imageManager.GetAllImage();
+ foreach (var image in images.items)
+ {
+ Console.WriteLine($"- ({image.Id}) : {(image.ImgPath.Length <= 40 ? image.ImgPath : image.ImgPath.Substring(0, 40)+"...")}");
+
+
+ }
+ Console.WriteLine("");
+
+
+ await imageManager.UpdateImage(12, new Images() { ImgPath = "https://testUpdate/stub"});
+ Console.WriteLine("---- Test mise a jour image (id : 12)");
+ images = await imageManager.GetAllImage();
+ foreach (var image in images.items)
+ {
+ Console.WriteLine($"- ({image.Id}) : {(image.ImgPath.Length <= 40 ? image.ImgPath : image.ImgPath.Substring(0, 40) + "...")}");
+ }
+ Console.WriteLine("");
+
+
+ await imageManager.RemoveImage(12);
+ Console.WriteLine("---- Test suppression image (id : 12)");
+ images = await imageManager.GetAllImage();
+ foreach (var image in images.items)
+ {
+ Console.WriteLine($"- ({image.Id}) : {(image.ImgPath.Length <= 40 ? image.ImgPath : image.ImgPath.Substring(0, 40) + "...")}");
+ }
+ Console.WriteLine("");
+
+
+ Console.WriteLine("---- Test getById image (id : 11)");
+ var img = await imageManager.GetImageById(11);
+ Console.WriteLine($"- ({img.Id}) : {(img.ImgPath.Length <= 40 ? img.ImgPath : img.ImgPath.Substring(0, 40) + "...")}");
+ Console.WriteLine("");
+
+
+ Console.WriteLine("---- Test getSomme image (nb : 5, page : 1)");
+ images = await imageManager.GetSomeImage(1,5);
+ foreach (var image in images.items)
+ {
+ Console.WriteLine($"- ({image.Id}) : {(image.ImgPath.Length <= 40 ? image.ImgPath : image.ImgPath.Substring(0, 40) + "...")}");
+ }
+ Console.WriteLine("");
+
+
+ Console.WriteLine("---- Test LastId image");
+ var id = await imageManager.GetLastImageId();
+ Console.WriteLine($"- Last image id : {id}");
+ Console.WriteLine("");
+
+ Console.WriteLine("-------------------------------------------------------------------------------");
+
+ // ---- Test Character ---- //
+
+ var characterManager = new DbCharacterManager(_context);
+
+
+ await characterManager.AddCharacter(new Character() { Id = 11, Name = "Vipélière", IdImage = 11 });
+ Console.WriteLine("---- Test ajout charcter (id : 11)");
+ var characters = await characterManager.GetAll();
+ foreach (var charac in characters.items)
+ {
+ Console.WriteLine($"- ({charac.Id}) : {charac.Name} -> {charac.IdImage} : {(charac.Images.ImgPath.Length <= 40 ? charac.Images.ImgPath : charac.Images.ImgPath.Substring(0, 40) + "...")}");
+ }
+ Console.WriteLine("");
+
+
+ await characterManager.UpdateCharacter(11,new Character() {Name = "Majespic"});
+ Console.WriteLine("---- Test mise a jour charcter (id : 11)");
+ characters = await characterManager.GetAll();
+ foreach (var charac in characters.items)
+ {
+ Console.WriteLine($"- ({charac.Id}) : {charac.Name} -> {charac.IdImage} : {(charac.Images.ImgPath.Length <= 40 ? charac.Images.ImgPath : charac.Images.ImgPath.Substring(0, 40) + "...")}");
+ }
+ Console.WriteLine("");
+
+
+ await characterManager.RemoveCharacter(11);
+ Console.WriteLine("---- Test sup (id : 5)");
+ characters = await characterManager.GetAll();
+ foreach (var charac in characters.items)
+ {
+ Console.WriteLine($"- ({charac.Id}) : {charac.Name} -> {charac.IdImage} : {(charac.Images.ImgPath.Length <= 40 ? charac.Images.ImgPath : charac.Images.ImgPath.Substring(0, 40) + "...")}");
+ }
+ Console.WriteLine("");
+
+
+ Console.WriteLine("---- Test GetById (id : 5)");
+ var chara = await characterManager.GetCharById(5);
+ Console.WriteLine($"- ({chara.Id}) : {chara.Name} -> {chara.IdImage} : {(chara.Images.ImgPath.Length <= 40 ? chara.Images.ImgPath : chara.Images.ImgPath.Substring(0, 40) + "...")}");
+ Console.WriteLine("");
+
+
+ Console.WriteLine("---- Test GetByName (name : Jon Snow)");
+ chara = await characterManager.GetCharByName("Jon Snow");
+ Console.WriteLine($"- ({chara.Id}) : {chara.Name} -> {chara.IdImage} : {(chara.Images.ImgPath.Length <= 40 ? chara.Images.ImgPath : chara.Images.ImgPath.Substring(0, 40) + "...")}");
+ Console.WriteLine("");
+
+
+ Console.WriteLine("---- Test LastId Character");
+ id = await characterManager.GetLastCharId();
+ Console.WriteLine($"- Last character id : {id}");
+ Console.WriteLine("");
+}
+
+
+
diff --git a/WF_EF_Api/Contextlib/Contextlib.csproj b/WF_EF_Api/Contextlib/Contextlib.csproj
index 805901c..d2b9100 100644
--- a/WF_EF_Api/Contextlib/Contextlib.csproj
+++ b/WF_EF_Api/Contextlib/Contextlib.csproj
@@ -22,6 +22,7 @@
+
diff --git a/WF_EF_Api/Contextlib/DbCharacterManager.cs b/WF_EF_Api/Contextlib/DbCharacterManager.cs
index 65f19e9..e0d75e1 100644
--- a/WF_EF_Api/Contextlib/DbCharacterManager.cs
+++ b/WF_EF_Api/Contextlib/DbCharacterManager.cs
@@ -13,10 +13,6 @@ namespace Contextlib
{
private WTFContext _context;
- ///
- /// Initializes a new instance of the class.
- ///
- /// The instance used to interact with the database.
public DbCharacterManager(WTFContext context)
{
_context = context ?? throw new ArgumentNullException(nameof(context), "Database context cannot be null.");
@@ -45,14 +41,9 @@ namespace Contextlib
/// A task representing the asynchronous operation, with a as its result containing the full list of characters and pagination information.
public Task> GetAll()
{
- List charLst = _context.characters.ToList();
-
- return Task.FromResult(new PaginationResult(
- charLst.Count, // Total count of characters in the database
- 0, // Current page (in this case, no pagination logic implemented)
- charLst.Count, // Total number of items (same as count for no pagination)
- charLst // The list of characters
- ));
+ List charLst = _context.characters.Include(i => i.Images).ToList();
+
+ return Task.FromResult(new PaginationResult(charLst.Count, 0, charLst.Count, charLst));
}
///
@@ -64,6 +55,7 @@ namespace Contextlib
public async Task GetCharById(int id)
{
Character? character = await _context.characters
+ .Include(i => i.Images)
.FirstOrDefaultAsync(x => x.Id == id);
if (character == null)
@@ -82,8 +74,9 @@ namespace Contextlib
/// Thrown when no character is found with the given name.
public async Task GetCharByName(string name)
{
- Character? character = await _context.characters
- .FirstOrDefaultAsync(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
+ var character = await _context.characters
+ .Where(c => EF.Functions.Like(c.Name, name))
+ .FirstOrDefaultAsync();
if (character == null)
{
@@ -138,17 +131,26 @@ namespace Contextlib
{
throw new ArgumentNullException(nameof(character), "The updated character data cannot be null.");
}
-
+ var modif = false;
Character? charUpdated = await _context.characters.FirstOrDefaultAsync(x => x.Id == id);
if (charUpdated == null)
{
throw new KeyNotFoundException($"Error : Unable to update, no character found with the ID: {id} .");
}
-
- charUpdated.IdImage = character.IdImage;
- charUpdated.Name = character.Name;
-
- await _context.SaveChangesAsync();
+ if (character.IdImage != 0)
+ {
+ charUpdated.IdImage = character.IdImage;
+ modif = true;
+ }
+ if (character.Name != null)
+ {
+ charUpdated.Name = character.Name;
+ modif = true;
+ }
+ if (modif)
+ {
+ await _context.SaveChangesAsync();
+ }
}
}
}
diff --git a/WF_EF_Api/Contextlib/DbCommentaryManager.cs b/WF_EF_Api/Contextlib/DbCommentaryManager.cs
new file mode 100644
index 0000000..e5bde4f
--- /dev/null
+++ b/WF_EF_Api/Contextlib/DbCommentaryManager.cs
@@ -0,0 +1,193 @@
+using Entity;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Update;
+using Shared;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Contextlib
+{
+ public class DbCommentManager : ICommentService
+ {
+ private WTFContext _context;
+
+ public DbCommentManager(WTFContext context)
+ {
+ _context = context ?? throw new ArgumentNullException(nameof(context), "Database context cannot be null.");
+ }
+
+ ///
+ /// Adds a new comment to the database.
+ ///
+ /// The comment to add.
+ /// A task representing the asynchronous operation.
+ /// Thrown when the comment is null.
+ public async Task AddComment(Commentary comment)
+ {
+ if (comment == null)
+ {
+ throw new ArgumentNullException(nameof(comment), "Comment cannot be null.");
+ }
+
+ await _context.comments.AddAsync(comment);
+ await _context.SaveChangesAsync();
+ }
+
+ ///
+ /// Deletes all comments associated with a specific quote ID from the database.
+ ///
+ /// The ID of the quote whose comments need to be deleted.
+ /// A task representing the asynchronous operation.
+ /// Thrown when no comments are found for the provided quote ID.
+ public async Task DeleteCommentForQuote(int quoteId)
+ {
+ var comments = await _context.comments.Where(x => x.IdQuote == quoteId).ToListAsync();
+ if (!comments.Any())
+ {
+ throw new KeyNotFoundException($"No comments found for the quote ID: {quoteId}.");
+ }
+
+ _context.comments.RemoveRange(comments);
+ await _context.SaveChangesAsync();
+ }
+
+ ///
+ /// Deletes all comments associated with a specific user ID from the database.
+ ///
+ /// The ID of the user whose comments need to be deleted.
+ /// A task representing the asynchronous operation.
+ /// Thrown when no comments are found for the provided user ID.
+ public async Task DeleteCommentForUser(int userId)
+ {
+ var comments = await _context.comments.Include(c => c.User).Where(x => x.IdUser == userId).ToListAsync();
+ if (!comments.Any())
+ {
+ throw new KeyNotFoundException($"No comments found for the user ID: {userId}.");
+ }
+
+ _context.comments.RemoveRange(comments);
+ await _context.SaveChangesAsync();
+ }
+
+ public async Task> GetAllComment()
+ {
+ var comments = await _context.comments.Include(c => c.User).ToListAsync();
+ return new PaginationResult(comments.Count, 0, comments.Count, comments);
+ }
+
+ public async Task GetCommentById(int id)
+ {
+ var comment = await _context.comments.Include(c => c.User).Where(x => x.Id == id).FirstOrDefaultAsync();
+ if(comment == null)
+ {
+ throw new KeyNotFoundException($"No comments found with the given ID: {id}.");
+ }
+ return comment;
+ }
+
+ public async Task> GetCommentByQuote(int quoteId, int index, int pageSize)
+ {
+ var comments = await _context.comments.Include(c => c.User).Where(x => x.IdQuote == quoteId).ToListAsync();
+ if (!comments.Any())
+ {
+ throw new KeyNotFoundException($"No comments found for the quote ID: {quoteId}.");
+ }
+ if ((index * pageSize + pageSize) > comments.Count)
+ {
+ if (pageSize > comments.Count)
+ {
+ return new PaginationResult(comments.Count(), index, pageSize, comments);
+ }
+ else
+ {
+ return new PaginationResult(pageSize, index, pageSize, comments.Skip(index * pageSize - (((index * pageSize) + pageSize) - comments.Count)).Take(pageSize).ToList());
+ }
+
+ }
+ return new PaginationResult(comments.Count, index, pageSize, comments.Skip(index * pageSize).Take(pageSize).ToList());
+ }
+
+ public async Task> GetCommentByUser(int userId, int index, int pageSize)
+ {
+ var comments = await _context.comments.Include(c => c.User).Where(x => x.IdUser == userId).ToListAsync();
+ if (!comments.Any())
+ {
+ throw new KeyNotFoundException($"No comments found for the user ID: {userId}.");
+ }
+ if ((index * pageSize + pageSize) > comments.Count)
+ {
+ if (pageSize > comments.Count)
+ {
+ return new PaginationResult(comments.Count(), index, pageSize, comments);
+ }
+ else
+ {
+ return new PaginationResult(pageSize, index, pageSize, comments.Skip(index * pageSize - (((index * pageSize) + pageSize) - comments.Count)).Take(pageSize).ToList());
+ }
+
+ }
+ return new PaginationResult(comments.Count, index, pageSize, comments.Skip(index * pageSize).Take(pageSize).ToList());
+ }
+
+ public async Task LastCommentId()
+ {
+ var last = await _context.comments.OrderByDescending(x => x.Id).FirstOrDefaultAsync();
+ if(last == null)
+ {
+ return 0;
+ }
+ return last.Id;
+ }
+
+ public async Task RemoveComment(int id)
+ {
+ var comment = await _context.comments.Where(x => x.Id == id).FirstOrDefaultAsync();
+ if (comment == null)
+ {
+ throw new KeyNotFoundException($"No comments found with the given ID: {id}.");
+ }
+ _context.comments.Remove(comment);
+ await _context.SaveChangesAsync();
+ }
+
+ public async Task UpdateComment(int id, Commentary comment)
+ {
+ var modif = false;
+ var com = await _context.comments.Where(x => x.Id == id).FirstOrDefaultAsync();
+ if (comment == null)
+ {
+ throw new ArgumentNullException(nameof(comment), "The updated comment data cannot be null.");
+ }
+ if (com == null)
+ {
+ throw new KeyNotFoundException($"No comments found with the given ID: {id}.");
+ }
+ if (comment.Comment != null)
+ {
+ com.Comment = comment.Comment;
+ modif = true;
+ }
+ if(comment.DateCommentary != null){
+ com.DateCommentary = comment.DateCommentary;
+ modif = true;
+ }
+ if(comment.IdQuote != 0)
+ {
+ com.IdQuote = comment.IdQuote;
+ modif = true;
+ }
+ if (comment.IdUser != 0)
+ {
+ com.IdUser = comment.IdUser;
+ modif = true;
+ }
+ if (modif)
+ {
+ await _context.SaveChangesAsync();
+ }
+ }
+ }
+}
diff --git a/WF_EF_Api/Contextlib/DbFavoriteManager.cs b/WF_EF_Api/Contextlib/DbFavoriteManager.cs
new file mode 100644
index 0000000..314da25
--- /dev/null
+++ b/WF_EF_Api/Contextlib/DbFavoriteManager.cs
@@ -0,0 +1,40 @@
+using Entity;
+using Shared;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Contextlib
+{
+ public class DbFavoriteManager : IFavoriteService
+ {
+ private WTFContext _context;
+
+ public DbFavoriteManager(WTFContext context)
+ {
+ _context = context ?? throw new ArgumentNullException(nameof(context), "Database context cannot be null.");
+ }
+
+ public async Task AddFavorite(int quoteid, int userId)
+ {
+ throw new NotImplementedException();
+ }
+
+ public async Task RemoveAllFavoriteForQuote(int quoteId)
+ {
+ throw new NotImplementedException();
+ }
+
+ public async Task RemoveAllFavoriteForUser(int userId)
+ {
+ throw new NotImplementedException();
+ }
+
+ public async Task RemoveFavorite(int quoteid, int userId)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/WF_EF_Api/Contextlib/DbImagesManager.cs b/WF_EF_Api/Contextlib/DbImagesManager.cs
new file mode 100644
index 0000000..ad51785
--- /dev/null
+++ b/WF_EF_Api/Contextlib/DbImagesManager.cs
@@ -0,0 +1,109 @@
+using Entity;
+using Microsoft.EntityFrameworkCore;
+using Shared;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace Contextlib
+{
+ public class DbImagesManager : IImagesService
+ {
+ private WTFContext _context;
+
+ public DbImagesManager(WTFContext context)
+ {
+ _context = context ?? throw new ArgumentNullException(nameof(context), "Database context cannot be null.");
+ }
+
+ public async Task AddImage(Images image)
+ {
+ await _context.AddAsync(image);
+ await _context.SaveChangesAsync();
+ }
+
+ public async Task> GetAllImage()
+ {
+ var images = await _context.images.ToListAsync();
+ return new PaginationResult(images.Count, 0, images.Count, images);
+ }
+
+ public async Task GetImageById(int id)
+ {
+ var image = await _context.images.Where(x => x.Id == id).FirstOrDefaultAsync();
+ if (image == null)
+ {
+ throw new KeyNotFoundException($"No image found with the given ID: {id}.");
+ }
+ return image;
+ }
+
+ public async Task GetLastImageId()
+ {
+ var last = await _context.images.OrderByDescending(x => x.Id).FirstOrDefaultAsync();
+ if (last == null)
+ {
+ return 0;
+ }
+ return last.Id;
+ }
+
+ public async Task> GetSomeImage(int index, int pageSize)
+ {
+ var images = await _context.images.ToListAsync();
+ if (!images.Any())
+ {
+ throw new KeyNotFoundException($"No images found");
+ }
+ if ((index * pageSize + pageSize) > images.Count)
+ {
+ if (pageSize > images.Count)
+ {
+ return new PaginationResult(images.Count(), index, pageSize, images);
+ }
+ else
+ {
+ return new PaginationResult(pageSize, index, pageSize, images.Skip(index * pageSize - (((index * pageSize) + pageSize) - images.Count)).Take(pageSize).ToList());
+ }
+ }
+ return new PaginationResult(images.Count, index, pageSize, images.Skip(index * pageSize).Take(pageSize).ToList());
+ }
+
+ public async Task RemoveImage(int id)
+ {
+ var image = await _context.images.Where(x => x.Id == id).FirstOrDefaultAsync();
+ if (image == null)
+ {
+ throw new KeyNotFoundException($"No image found with the given ID: {id}.");
+ }
+ _context.images.Remove(image);
+ await _context.SaveChangesAsync();
+ }
+
+ public async Task UpdateImage(int id, Images image)
+ {
+ var modif = false;
+ var img = await _context.images.Where(x => x.Id == id).FirstOrDefaultAsync();
+ if (image == null)
+ {
+ throw new ArgumentNullException(nameof(image), "The updated image data cannot be null.");
+ }
+ if (img == null)
+ {
+ throw new KeyNotFoundException($"No image found with the given ID: {id}.");
+ }
+ if (image.ImgPath != null)
+ {
+ img.ImgPath = image.ImgPath;
+ modif = true;
+ }
+ if (modif)
+ {
+ await _context.SaveChangesAsync();
+ }
+ }
+ }
+}
diff --git a/WF_EF_Api/Contextlib/DbQuestionSerice.cs b/WF_EF_Api/Contextlib/DbQuestionSerice.cs
new file mode 100644
index 0000000..010f38c
--- /dev/null
+++ b/WF_EF_Api/Contextlib/DbQuestionSerice.cs
@@ -0,0 +1,73 @@
+using Entity;
+using Shared;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Contextlib
+{
+ public class DbQuestionSerice : IQuestionService
+ {
+ public Task AddQuestion(Question question)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task CountQuestions()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task> GetAllQuestion()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task> GetInvalidQuestion(int index, int pageSize)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetQuestionById(int id)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetRandomQuestion()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetRandomQuestionQuoteToCharacter()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetRandomQuestionQuoteToSource()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task> GetSomeQuestion(int index, int pageSize)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task RemoveQuestion(int id)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task UpdateQuestion(int id, Question question)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task ValidateQuestion(int id, bool isvalid)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/WF_EF_Api/Contextlib/WTFContext.cs b/WF_EF_Api/Contextlib/WTFContext.cs
index 02880c7..4b95f3b 100644
--- a/WF_EF_Api/Contextlib/WTFContext.cs
+++ b/WF_EF_Api/Contextlib/WTFContext.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Entity;
@@ -10,7 +11,7 @@ namespace Contextlib
{
public class WTFContext : DbContext
{
- public DbSet admins { get; set; }
+ //public DbSet admins { get; set; }
public DbSet characters { get; set; }
public DbSet comments { get; set; }
public DbSet dailyquotes { get; set; }
@@ -18,14 +19,76 @@ namespace Contextlib
public DbSet images { get; set; }
public DbSet question { get; set; }
public DbSet quizzes { get; set; }
- public DbSet quizQuestions { get; set; }
+ //public DbSet quizQuestions { get; set; }
public DbSet quotes { get; set; }
//public DbSet records { get; set; }
public DbSet sources { get; set; }
public DbSet users { get; set; }
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
+
+ modelBuilder.Entity()
+ .HasMany(q => q.Favorite)
+ .WithMany(u => u.Favorite)
+ .UsingEntity(
+ l => l.HasOne(f => f.Quote)
+ .WithMany()
+ .OnDelete(DeleteBehavior.ClientCascade)
+ .HasForeignKey(f => f.IdQuote),
+ r => r.HasOne(f => f.Users)
+ .WithMany()
+ .OnDelete(DeleteBehavior.ClientCascade)
+ .HasForeignKey(f => f.IdUsers)
+ );
+
+ modelBuilder.Entity()
+ .HasMany(u => u.Quotes)
+ .WithOne(q => q.User)
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasForeignKey(q => q.IdUsersPropose);
+
+ modelBuilder.Entity()
+ .HasMany()
+ .WithMany()
+ .UsingEntity(
+ i => i.HasKey(e => new { e.IdUser, e.IdQuote })
+ );
+
+ modelBuilder.Entity()
+ .HasOne(c => c.User)
+ .WithMany()
+ .HasForeignKey(c => c.IdUser);
+
+ modelBuilder.Entity()
+ .HasMany(q => q.Commentarys)
+ .WithOne(c => c.Quote)
+ .OnDelete(DeleteBehavior.ClientCascade)
+ .HasForeignKey(c => c.IdQuote);
+
+ modelBuilder.Entity()
+ .HasMany(q => q.Questions)
+ .WithMany(u => u.Quizs)
+ .UsingEntity(
+ l => l.HasOne().WithMany().HasForeignKey(q => q.IdQuestion),
+ r => r.HasOne().WithMany().HasForeignKey(u => u.IdQuiz)
+ );
+ }
+
+ public WTFContext()
+ { }
+
+ public WTFContext(DbContextOptions options)
+ : base(options)
+ { }
protected override void OnConfiguring(DbContextOptionsBuilder options)
- => options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=WfDatabase.mdf;Trusted_Connection=True;");
+ {
+ if (!options.IsConfigured)
+ {
+ options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Wf-Database.mdf;Trusted_Connection=True;");
+ }
+ }
}
}
diff --git a/WF_EF_Api/Dto2Entities/Dto2Entities.csproj b/WF_EF_Api/Dto2Entities/Dto2Entities.csproj
new file mode 100644
index 0000000..beed701
--- /dev/null
+++ b/WF_EF_Api/Dto2Entities/Dto2Entities.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/WF_EF_Api/Entity/Commentary.cs b/WF_EF_Api/Entity/Commentary.cs
index 07649d2..92b2908 100644
--- a/WF_EF_Api/Entity/Commentary.cs
+++ b/WF_EF_Api/Entity/Commentary.cs
@@ -16,7 +16,7 @@ namespace Entity
[Required]
[ForeignKey(nameof(Users))]
- public int IdUsers { get; set; }
+ public int IdUser { get; set; }
[Required]
[ForeignKey(nameof(Quote))]
@@ -32,6 +32,6 @@ namespace Entity
public Quote Quote { get; set; } = null!;
- public Users Users { get; set; } = null!;
+ public Users User { get; set; } = null!;
}
}
diff --git a/WF_EF_Api/Entity/Favorite.cs b/WF_EF_Api/Entity/Favorite.cs
index 51165d5..06e1185 100644
--- a/WF_EF_Api/Entity/Favorite.cs
+++ b/WF_EF_Api/Entity/Favorite.cs
@@ -10,16 +10,12 @@ namespace Entity
{
public class Favorite
{
- [Key]
- [ForeignKey(nameof(Users))]
public int IdUsers { get; set; }
- [Key]
- [ForeignKey(nameof(Quote))]
- public int IdQuote { get; set; }
+ public Users Users { get; set; }
- public Users User { get; set; } = null!;
+ public int IdQuote { get; set; }
- public Quote Quote { get; set; } = null!;
+ public Quote Quote { get; set; }
}
}
diff --git a/WF_EF_Api/Entity/Question.cs b/WF_EF_Api/Entity/Question.cs
index df66009..b2e37e9 100644
--- a/WF_EF_Api/Entity/Question.cs
+++ b/WF_EF_Api/Entity/Question.cs
@@ -15,7 +15,7 @@ namespace Entity
public int Id { get; set; }
[Required]
- [StringLength(50)]
+ [StringLength(200)]
public string Text { get; set; }
[Required]
@@ -38,6 +38,6 @@ namespace Entity
[StringLength(1)]
public string CorrectAnswer { get; set; }
- public ICollection Quizs { get; } = new List();
+ public ICollection Quizs { get; set; } = new List();
}
}
diff --git a/WF_EF_Api/Entity/QuizQuestion.cs b/WF_EF_Api/Entity/QuizQuestion.cs
index eaf51c3..5e7086b 100644
--- a/WF_EF_Api/Entity/QuizQuestion.cs
+++ b/WF_EF_Api/Entity/QuizQuestion.cs
@@ -10,16 +10,8 @@ namespace Entity
{
public class QuizQuestion
{
- [Key]
- [ForeignKey(nameof(Quiz))]
public int IdQuiz { get; set; }
- [Key]
- [ForeignKey(nameof(Question))]
public int IdQuestion { get; set; }
-
- public Quiz Quiz { get; set; } = null!;
-
- public Question Question { get; set; } = null!;
}
}
diff --git a/WF_EF_Api/Entity/Quote.cs b/WF_EF_Api/Entity/Quote.cs
index adc1dd8..37d5f00 100644
--- a/WF_EF_Api/Entity/Quote.cs
+++ b/WF_EF_Api/Entity/Quote.cs
@@ -15,7 +15,7 @@ namespace Entity
public int Id { get; set; }
[Required]
- [StringLength(50)]
+ [StringLength(100)]
public string Content { get; set; }
[Required]
@@ -35,14 +35,21 @@ namespace Entity
[ForeignKey(nameof(Source))]
public int IdSource { get; set; }
- [Required]
[ForeignKey(nameof(Users))]
- public int IdUsersPropose { get; set; }
+ public int? IdUsersPropose { get; set; }
+ //Réson de pour quoi j'ai mis le user en nullable et mis .OnDelete(DeleteBehavior.ClientSetNull) dans WTFContext
+ //https://learn.microsoft.com/fr-fr/ef/core/saving/cascade-delete
+ //Les suppressions en cascade sont nécessaires quand une entité dépendante/enfant ne peut plus être associée à son entité principale/parente actuelle. Cela peut se produire à la suite de la suppression de l’entité principale/parente, ou quand l’entité principale/parente existe toujours mais que l’entité dépendante/enfant ne lui est plus associée.
+ public Users? User { get; set; } = null!;
+
+ public Source Source { get; set; } = null!;
+
+ public Character Character { get; set; } = null!;
public ICollection DailyQuotes { get; set; } = new List();
- public ICollection commentaries { get; set; } = new List();
+ public ICollection Commentarys { get; set; } = new List();
- public ICollection Favorite { get; set; } = new List();
+ public ICollection Favorite { get; } = new List();
}
}
diff --git a/WF_EF_Api/Entity/Source.cs b/WF_EF_Api/Entity/Source.cs
index 4a9f77c..60cda07 100644
--- a/WF_EF_Api/Entity/Source.cs
+++ b/WF_EF_Api/Entity/Source.cs
@@ -15,7 +15,7 @@ namespace Entity
public int Id { get; set; }
[Required]
- [StringLength(50)]
+ [StringLength(100)]
public string Title { get; set; }
[Required]
diff --git a/WF_EF_Api/Entity/Users.cs b/WF_EF_Api/Entity/Users.cs
index 81aa506..e7a8101 100644
--- a/WF_EF_Api/Entity/Users.cs
+++ b/WF_EF_Api/Entity/Users.cs
@@ -37,8 +37,6 @@ namespace Entity
public ICollection Quotes { get; set; } = new List();
- public ICollection Commentary { get; set; } = new List();
-
- public ICollection Favorite { get; set; } = new List();
+ public ICollection Favorite { get; set; } = new List();
}
}
diff --git a/WF_EF_Api/Shared/IComentaryService.cs b/WF_EF_Api/Shared/IComentaryService.cs
index 2cf4fe1..d5c4fc6 100644
--- a/WF_EF_Api/Shared/IComentaryService.cs
+++ b/WF_EF_Api/Shared/IComentaryService.cs
@@ -46,7 +46,7 @@ namespace Shared
// Deletes all comments made by a specific user.
// 'userId' is the unique identifier of the user whose comments will be deleted.
- Task DeleteCommentForuser(int userId);
+ Task DeleteCommentForUser(int userId);
// Retrieves the last comment ID.
Task LastCommentId();
diff --git a/WF_EF_Api/Shared/IImagesService.cs b/WF_EF_Api/Shared/IImagesService.cs
index e2d0465..0bc6bf0 100644
--- a/WF_EF_Api/Shared/IImagesService.cs
+++ b/WF_EF_Api/Shared/IImagesService.cs
@@ -10,7 +10,7 @@ namespace Shared
{
// Retrieves an image by its unique identifier (id).
// 'id' is the unique identifier of the image.
- Task GetImageById(string id);
+ Task GetImageById(int id);
// Retrieves all images, with pagination support.
// This returns a list of all images in the system.
diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250312160314_myFirstMigration.Designer.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250312160314_myFirstMigration.Designer.cs
deleted file mode 100644
index 516d42a..0000000
--- a/WF_EF_Api/StubbedContextLib/Migrations/20250312160314_myFirstMigration.Designer.cs
+++ /dev/null
@@ -1,205 +0,0 @@
-//
-using System;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using StubbedContextLib;
-
-#nullable disable
-
-namespace StubbedContextLib.Migrations
-{
- [DbContext(typeof(StubWTFContext))]
- [Migration("20250312160314_myFirstMigration")]
- partial class myFirstMigration
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "9.0.3")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("Entity.Character", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Name")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("Character");
- });
-
- modelBuilder.Entity("Entity.Images", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("ImgPath")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("Images");
- });
-
- modelBuilder.Entity("Entity.Question", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("AnswerA")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("AnswerB")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("AnswerC")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("AnswerD")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("CorrectAnswer")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("Text")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("Question");
- });
-
- modelBuilder.Entity("Entity.Quiz", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("NbQuestion")
- .HasColumnType("int");
-
- b.Property("Title")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("Quiz");
- });
-
- modelBuilder.Entity("Entity.Quote", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Content")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("IsValid")
- .HasColumnType("bit");
-
- b.Property("Langage")
- .HasColumnType("int");
-
- b.Property("Likes")
- .HasColumnType("int");
-
- b.HasKey("Id");
-
- b.ToTable("Quote");
- });
-
- modelBuilder.Entity("Entity.Source", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Title")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("Year")
- .HasColumnType("int");
-
- b.HasKey("Id");
-
- b.ToTable("Source");
- });
-
- modelBuilder.Entity("Entity.Users", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Created")
- .HasColumnType("datetime2");
-
- b.Property("Email")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("Password")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("UserName")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("Users");
-
- b.HasData(
- new
- {
- Id = 1,
- Created = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
- Email = "dev@gmail.com",
- Password = "1234",
- UserName = "Dev"
- });
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250312160314_myFirstMigration.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250312160314_myFirstMigration.cs
deleted file mode 100644
index 6fd3de5..0000000
--- a/WF_EF_Api/StubbedContextLib/Migrations/20250312160314_myFirstMigration.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace StubbedContextLib.Migrations
-{
- ///
- public partial class myFirstMigration : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Character",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Name = table.Column(type: "nvarchar(max)", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Character", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Images",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- ImgPath = table.Column(type: "nvarchar(max)", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Images", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Question",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Text = table.Column(type: "nvarchar(max)", nullable: false),
- AnswerA = table.Column(type: "nvarchar(max)", nullable: false),
- AnswerB = table.Column(type: "nvarchar(max)", nullable: false),
- AnswerC = table.Column(type: "nvarchar(max)", nullable: false),
- AnswerD = table.Column(type: "nvarchar(max)", nullable: false),
- CorrectAnswer = table.Column(type: "nvarchar(max)", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Question", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Quiz",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Title = table.Column(type: "nvarchar(max)", nullable: false),
- NbQuestion = table.Column(type: "int", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Quiz", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Quote",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Content = table.Column(type: "nvarchar(max)", nullable: false),
- Likes = table.Column(type: "int", nullable: false),
- Langage = table.Column(type: "int", nullable: false),
- IsValid = table.Column(type: "bit", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Quote", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Source",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Title = table.Column(type: "nvarchar(max)", nullable: false),
- Year = table.Column(type: "int", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Source", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Users",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- UserName = table.Column(type: "nvarchar(max)", nullable: false),
- Email = table.Column(type: "nvarchar(max)", nullable: false),
- Password = table.Column(type: "nvarchar(max)", nullable: false),
- Created = table.Column(type: "datetime2", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Users", x => x.Id);
- });
-
- migrationBuilder.InsertData(
- table: "Users",
- columns: new[] { "Id", "Created", "Email", "Password", "UserName" },
- values: new object[] { 1, new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "dev@gmail.com", "1234", "Dev" });
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Character");
-
- migrationBuilder.DropTable(
- name: "Images");
-
- migrationBuilder.DropTable(
- name: "Question");
-
- migrationBuilder.DropTable(
- name: "Quiz");
-
- migrationBuilder.DropTable(
- name: "Quote");
-
- migrationBuilder.DropTable(
- name: "Source");
-
- migrationBuilder.DropTable(
- name: "Users");
- }
- }
-}
diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250312162514_migr2.Designer.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250312162514_migr2.Designer.cs
deleted file mode 100644
index d84e486..0000000
--- a/WF_EF_Api/StubbedContextLib/Migrations/20250312162514_migr2.Designer.cs
+++ /dev/null
@@ -1,248 +0,0 @@
-//
-using System;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using StubbedContextLib;
-
-#nullable disable
-
-namespace StubbedContextLib.Migrations
-{
- [DbContext(typeof(StubWTFContext))]
- [Migration("20250312162514_migr2")]
- partial class migr2
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "9.0.3")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("Entity.Character", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Name")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("Character");
- });
-
- modelBuilder.Entity("Entity.Images", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("ImgPath")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("Images");
-
- b.HasData(
- new
- {
- Id = 1,
- ImgPath = "coucou"
- },
- new
- {
- Id = 2,
- ImgPath = "bonjour"
- });
- });
-
- modelBuilder.Entity("Entity.Question", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("AnswerA")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("AnswerB")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("AnswerC")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("AnswerD")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("CorrectAnswer")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("Text")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("Question");
- });
-
- modelBuilder.Entity("Entity.Quiz", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("NbQuestion")
- .HasColumnType("int");
-
- b.Property("Title")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("Quiz");
- });
-
- modelBuilder.Entity("Entity.Quote", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Content")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("IsValid")
- .HasColumnType("bit");
-
- b.Property("Langage")
- .HasColumnType("int");
-
- b.Property("Likes")
- .HasColumnType("int");
-
- b.HasKey("Id");
-
- b.ToTable("Quote");
- });
-
- modelBuilder.Entity("Entity.Source", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Title")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("Year")
- .HasColumnType("int");
-
- b.HasKey("Id");
-
- b.ToTable("Source");
- });
-
- modelBuilder.Entity("Entity.Users", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Created")
- .HasColumnType("datetime2");
-
- b.Property("Email")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("IdImage")
- .HasColumnType("int");
-
- b.Property("Password")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("UserName")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.HasIndex("IdImage");
-
- b.ToTable("Users");
-
- b.HasData(
- new
- {
- Id = 1,
- Created = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
- Email = "dev@gmail.com",
- IdImage = 1,
- Password = "1234",
- UserName = "Dev"
- },
- new
- {
- Id = 2,
- Created = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
- Email = "admin@gmail.com",
- IdImage = 1,
- Password = "1234",
- UserName = "Admin"
- });
- });
-
- modelBuilder.Entity("Entity.Users", b =>
- {
- b.HasOne("Entity.Images", "Images")
- .WithMany("Users")
- .HasForeignKey("IdImage")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Images");
- });
-
- modelBuilder.Entity("Entity.Images", b =>
- {
- b.Navigation("Users");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250312162514_migr2.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250312162514_migr2.cs
deleted file mode 100644
index 01e2609..0000000
--- a/WF_EF_Api/StubbedContextLib/Migrations/20250312162514_migr2.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
-
-namespace StubbedContextLib.Migrations
-{
- ///
- public partial class migr2 : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AddColumn(
- name: "IdImage",
- table: "Users",
- type: "int",
- nullable: false,
- defaultValue: 0);
-
- migrationBuilder.InsertData(
- table: "Images",
- columns: new[] { "Id", "ImgPath" },
- values: new object[,]
- {
- { 1, "coucou" },
- { 2, "bonjour" }
- });
-
- migrationBuilder.UpdateData(
- table: "Users",
- keyColumn: "Id",
- keyValue: 1,
- column: "IdImage",
- value: 1);
-
- migrationBuilder.InsertData(
- table: "Users",
- columns: new[] { "Id", "Created", "Email", "IdImage", "Password", "UserName" },
- values: new object[] { 2, new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "admin@gmail.com", 1, "1234", "Admin" });
-
- migrationBuilder.CreateIndex(
- name: "IX_Users_IdImage",
- table: "Users",
- column: "IdImage");
-
- migrationBuilder.AddForeignKey(
- name: "FK_Users_Images_IdImage",
- table: "Users",
- column: "IdImage",
- principalTable: "Images",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_Users_Images_IdImage",
- table: "Users");
-
- migrationBuilder.DropIndex(
- name: "IX_Users_IdImage",
- table: "Users");
-
- migrationBuilder.DeleteData(
- table: "Images",
- keyColumn: "Id",
- keyValue: 2);
-
- migrationBuilder.DeleteData(
- table: "Users",
- keyColumn: "Id",
- keyValue: 2);
-
- migrationBuilder.DeleteData(
- table: "Images",
- keyColumn: "Id",
- keyValue: 1);
-
- migrationBuilder.DropColumn(
- name: "IdImage",
- table: "Users");
- }
- }
-}
diff --git a/WF_EF_Api/StubbedContextLib/Migrations/20250317163102_migrationTest1.Designer.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250317163102_migrationTest1.Designer.cs
new file mode 100644
index 0000000..e352e28
--- /dev/null
+++ b/WF_EF_Api/StubbedContextLib/Migrations/20250317163102_migrationTest1.Designer.cs
@@ -0,0 +1,1065 @@
+//
+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/20250317163102_migrationTest1.cs b/WF_EF_Api/StubbedContextLib/Migrations/20250317163102_migrationTest1.cs
new file mode 100644
index 0000000..437370b
--- /dev/null
+++ b/WF_EF_Api/StubbedContextLib/Migrations/20250317163102_migrationTest1.cs
@@ -0,0 +1,492 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
+
+namespace StubbedContextLib.Migrations
+{
+ ///
+ public partial class migrationTest1 : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "images",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ ImgPath = table.Column(type: "nvarchar(max)", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_images", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "question",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ Text = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false),
+ AnswerA = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false),
+ AnswerB = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false),
+ AnswerC = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false),
+ AnswerD = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false),
+ CorrectAnswer = table.Column(type: "nvarchar(1)", maxLength: 1, nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_question", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "sources",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ Title = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false),
+ Year = table.Column(type: "int", nullable: false),
+ TypeSrc = table.Column(type: "int", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_sources", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "characters",
+ columns: table => new
+ {
+ Id = table.Column