initialisation merge
continuous-integration/drone/push Build is failing Details

pull/6/head
Kentin BRONGNIART 4 weeks ago
commit 0b1c5b0208

@ -1,6 +1,59 @@
# WF-PmAPI
### Paquets
NSwag.AspNetCore <br>
Moq
🟨 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 |

@ -7,4 +7,12 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StubbedContextLib\StubbedContextLib.csproj" />
</ItemGroup>
</Project>

@ -1 +1,134 @@
Console.WriteLine("bonjour");
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<WTFContext>()
.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 = 0, 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 = 0, 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 = 0, 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("");
}

@ -18,6 +18,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NLog" Version="5.4.0" />
</ItemGroup>
<ItemGroup>

@ -12,14 +12,12 @@ namespace Contextlib
public class DbCharacterManager : ICharacterService<Character>
{
private WTFContext _context;
private GenericRepository<Character> _repo;
/// <summary>
/// Initializes a new instance of the <see cref="DbCharacterManager"/> class.
/// </summary>
/// <param name="context">The <see cref="WTFContext"/> instance used to interact with the database.</param>
public DbCharacterManager(WTFContext context)
{
_context = context ?? throw new ArgumentNullException(nameof(context), "Database context cannot be null.");
_repo = new GenericRepository<Character>(_context);
}
/// <summary>
@ -32,10 +30,9 @@ namespace Contextlib
{
if (character == null)
{
throw new ArgumentNullException(nameof(character), "Character cannot be null.");
throw new ArgumentNullException(nameof(character), "character cannot be null.");
}
await _context.AddAsync(character);
_repo.Insert(character);
await _context.SaveChangesAsync();
}
@ -43,16 +40,10 @@ namespace Contextlib
/// Retrieves all characters from the database and returns them in a paginated format.
/// </summary>
/// <returns>A task representing the asynchronous operation, with a <see cref="PaginationResult{Character}"/> as its result containing the full list of characters and pagination information.</returns>
public Task<PaginationResult<Character>> GetAll()
public async Task<PaginationResult<Character>> GetAll()
{
List<Character> charLst = _context.characters.ToList();
return Task.FromResult(new PaginationResult<Character>(
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<Character> charLst = _repo.GetItems(0, _repo.Count(), [nameof(Character.Images)]).ToList();
return new PaginationResult<Character>(charLst.Count, 0, charLst.Count, charLst);
}
/// <summary>
@ -63,14 +54,11 @@ namespace Contextlib
/// <exception cref="KeyNotFoundException">Thrown when no character is found with the given ID.</exception>
public async Task<Character> GetCharById(int id)
{
Character? character = await _context.characters
.FirstOrDefaultAsync(x => x.Id == id);
Character? character = _repo.GetById(id, item => item.Id == id, nameof(Character.Images));
if (character == null)
{
throw new KeyNotFoundException($"Error : No character found with the ID: {id}.");
}
return character;
}
@ -82,8 +70,7 @@ namespace Contextlib
/// <exception cref="KeyNotFoundException">Thrown when no character is found with the given name.</exception>
public async Task<Character> GetCharByName(string name)
{
Character? character = await _context.characters
.FirstOrDefaultAsync(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
var character = _repo.GetItems(item => item.Name == name,0,1, [nameof(Character.Images)]).FirstOrDefault();
if (character == null)
{
@ -99,11 +86,16 @@ namespace Contextlib
/// <returns>The highest character ID in the database. 0 if there is no character in the database</returns>
public async Task<int> GetLastCharId()
{
int id = await _context.characters
.OrderByDescending(x => x.Id)
.Select(x => x.Id)
.FirstOrDefaultAsync();
return id;
PaginationResult<Character> characters = await GetAll();
int lastCharId = 0;
foreach (Character character in characters.items)
{
if (character.Id >= lastCharId)
{
lastCharId = character.Id + 1;
}
}
return lastCharId;
}
/// <summary>
@ -114,13 +106,7 @@ namespace Contextlib
/// <exception cref="KeyNotFoundException">Thrown when no character is found with the given ID.</exception>
public async Task RemoveCharacter(int id)
{
Character? character = await _context.characters.FirstOrDefaultAsync(x => x.Id == id);
if (character == null)
{
throw new KeyNotFoundException($"Error : Unable to delete, no character found with the ID: {id}.");
}
_context.characters.Remove(character);
_repo.Delete(id);
await _context.SaveChangesAsync();
}
@ -134,21 +120,23 @@ namespace Contextlib
/// <exception cref="KeyNotFoundException">Thrown when no character is found with the given ID.</exception>
public async Task UpdateCharacter(int id, Character character)
{
if (character == null)
Character? charac = _repo.GetById(id);
if (charac != null && charac != null)
{
throw new ArgumentNullException(nameof(character), "The updated character data cannot be null.");
bool change = false;
if (character.IdImage != 0)
{
charac.IdImage = character.IdImage;
change = true;
}
if (character.Name != null)
{
charac.Name = character.Name;
change = true;
}
_repo.Update(charac);
if (change) _context.SaveChanges();
}
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();
}
}
}

@ -0,0 +1,190 @@
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<Commentary>
{
private WTFContext _context;
private GenericRepository<Commentary> _repo;
public DbCommentManager(WTFContext context)
{
_context = context ?? throw new ArgumentNullException(nameof(context), "Database context cannot be null.");
_repo = new GenericRepository<Commentary>(context);
}
/// <summary>
/// Adds a new comment to the database.
/// </summary>
/// <param name="comment">The comment to add.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <exception cref="ArgumentNullException">Thrown when the comment is null.</exception>
public async Task AddComment(Commentary comment)
{
if (comment == null)
{
throw new ArgumentNullException(nameof(comment), "Comment cannot be null.");
}
_repo.Insert(comment);
await _context.SaveChangesAsync();
}
/// <summary>
/// Deletes all comments associated with a specific quote ID from the database.
/// </summary>
/// <param name="quoteId">The ID of the quote whose comments need to be deleted.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <exception cref="KeyNotFoundException">Thrown when no comments are found for the provided quote ID.</exception>
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();
}
/// <summary>
/// Deletes all comments associated with a specific user ID from the database.
/// </summary>
/// <param name="userId">The ID of the user whose comments need to be deleted.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <exception cref="KeyNotFoundException">Thrown when no comments are found for the provided user ID.</exception>
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<PaginationResult<Commentary>> GetAllComment()
{
var comments = await _context.comments.Include(c => c.User).ToListAsync();
return new PaginationResult<Commentary>(comments.Count, 0, comments.Count, comments);
}
public async Task<Commentary> 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<PaginationResult<Commentary>> 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<Commentary>(comments.Count(), index, pageSize, comments);
}
else
{
return new PaginationResult<Commentary>(pageSize, index, pageSize, comments.Skip(index * pageSize - (((index * pageSize) + pageSize) - comments.Count)).Take(pageSize).ToList());
}
}
return new PaginationResult<Commentary>(comments.Count, index, pageSize, comments.Skip(index * pageSize).Take(pageSize).ToList());
}
public async Task<PaginationResult<Commentary>> 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<Commentary>(comments.Count(), index, pageSize, comments);
}
else
{
return new PaginationResult<Commentary>(pageSize, index, pageSize, comments.Skip(index * pageSize - (((index * pageSize) + pageSize) - comments.Count)).Take(pageSize).ToList());
}
}
return new PaginationResult<Commentary>(comments.Count, index, pageSize, comments.Skip(index * pageSize).Take(pageSize).ToList());
}
public async Task<int> 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)
{
_repo.Delete(id);
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();
}
}
}
}

@ -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();
}
}
}

@ -0,0 +1,90 @@
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<Images>
{
private WTFContext _context;
private GenericRepository<Images> _repository;
public DbImagesManager(WTFContext context)
{
_context = context ?? throw new ArgumentNullException(nameof(context), "Database context cannot be null.");
_repository = new GenericRepository<Images>(context);
}
public async Task AddImage(Images image)
{
_repository.Insert(image);
await _context.SaveChangesAsync();
}
public async Task<PaginationResult<Images>> GetAllImage()
{
return new PaginationResult<Images>(await CountImage(), 0, await CountImage(), _repository.GetItems(0, await CountImage()).ToList());
}
public async Task<Images> GetImageById(int id)
{
return _repository.GetById(id);
}
public async Task<int> GetLastImageId()
{
var last = await GetAllImage();
int id = 1;
{
foreach (Images image in last.items)
{
if(image.Id >= id)
id = image.Id + 1;
}
}
return id;
}
public async Task<PaginationResult<Images>> GetSomeImage(int index, int pageSize)
{
var images = _repository.GetItems(index, pageSize);
return new PaginationResult<Images>(images.Count(),index,pageSize,images.ToList());
}
public async Task RemoveImage(int id)
{
_repository.Delete(id);
await _context.SaveChangesAsync();
}
public async Task UpdateImage(int id, Images image)
{
var img = _repository.GetById(id);
var modif = false;
if (image != null && img != null)
{
if (image.ImgPath != null)
{
img.ImgPath = image.ImgPath;
modif = true;
}
_repository.Update(img);
if (modif)
{
await _context.SaveChangesAsync();
}
}
}
public async Task<int> CountImage()
{
return await _context.images.CountAsync();
}
}
}

@ -0,0 +1,155 @@
using Entity;
using Microsoft.EntityFrameworkCore;
using Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contextlib
{
public class DbQuestionManager : IQuestionService<Question>
{
private WTFContext _context;
private GenericRepository<Question> _repository;
public DbQuestionManager(WTFContext context)
{
_context = context ?? throw new ArgumentNullException(nameof(context), "Database context cannot be null.");
_repository = new GenericRepository<Question>(context);
}
public async Task AddQuestion(Question question)
{
_repository.Insert(question);
await _context.SaveChangesAsync();
}
public async Task<int> CountQuestions()
{
return _repository.Count();
}
public async Task<PaginationResult<Question>> GetAllQuestion()
{
return new PaginationResult<Question>(_repository.Count(), 0, _repository.Count(), _repository.GetItems(0,_repository.Count()).ToList());
}
public async Task<PaginationResult<Question>> GetInvalidQuestion(int index, int pageSize)
{
List<Question> questionList = _repository.GetItems(item => item.IsValid == false, index, pageSize).ToList();
return new PaginationResult<Question>(questionList.Count(), index, pageSize, questionList);
}
public async Task<Question> GetQuestionById(int id)
{
return _repository.GetById(id);
}
public async Task<Question> GetRandomQuestion()
{
Random rnd = new Random();
Question? question = null;
while(question == null)
{
question = await GetQuestionById(rnd.Next(0, await LastId()-1));
}
return question;
}
public async Task<Question> GetRandomQuestionQuoteToCharacter()
{
//dabord implémenter get random quote
throw new NotImplementedException();
}
public async Task<Question> GetRandomQuestionQuoteToSource()
{
//dabord implémenter get random quote
throw new NotImplementedException();
}
public async Task<PaginationResult<Question>> GetSomeQuestion(int index, int pageSize)
{
List<Question> questionList = _repository.GetItems(item => item.IsValid == false, index, pageSize).ToList();
return new PaginationResult<Question>(questionList.Count(), index, pageSize, questionList);
}
public async Task RemoveQuestion(int id)
{
_repository.Delete(id);
await _context.SaveChangesAsync();
}
public async Task UpdateQuestion(int id, Question question)
{
Question? questionUpdated = await GetQuestionById(id);
if (question != null && questionUpdated != null)
{
bool modified = false;
if (question.IsValid != questionUpdated.IsValid)
{
questionUpdated.IsValid = question.IsValid;
modified = true;
}
if (question.Text != null)
{
questionUpdated.Text = question.Text;
modified = true;
}
if (question.AnswerA != null)
{
questionUpdated.AnswerA = question.AnswerA;
modified = true;
}
if (question.AnswerB != null)
{
questionUpdated.AnswerB = question.AnswerB;
modified = true;
}
if (question.AnswerC != null)
{
questionUpdated.AnswerC = question.AnswerC;
modified = true;
}
if (question.AnswerD != null)
{
questionUpdated.AnswerD = question.AnswerD;
modified = true;
}
if (question.CorrectAnswer != null)
{
questionUpdated.CorrectAnswer = question.CorrectAnswer;
modified = true;
}
_repository.Update(questionUpdated);
if(modified) _context.SaveChanges();
}
;
}
public async Task ValidateQuestion(int id, bool isvalid)
{
Question? question = await GetQuestionById(id);
if (question == null) throw new KeyNotFoundException($"Aucune question avec l'id {id}");
question.IsValid = isvalid;
_repository.Update(question);
}
public async Task<int> LastId()
{
PaginationResult<Question> questions = await GetAllQuestion();
int id = 1;
foreach (Question question in questions.items)
{
if (question.Id >= id)
{
id = question.Id + 1;
}
}
return id;
}
}
}

@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
namespace Contextlib
{
public class GenericRepository<T> where T : class
{
private DbContext Context { get; set; }
private DbSet<T> Set { get; set; }
public GenericRepository(DbContext context)
{
Context = context;
Set = Context.Set<T>();
}
public virtual T? GetById(object id)
=> Set.Find(id);
public virtual T? GetById(object id, Expression<Func<T, bool>>? filter = null, params string[] includeProperties)
{
IQueryable<T> query = Set;
if (filter != null)
{
query = query.Where(filter);
}
foreach (string includeProperty in includeProperties)
{
query = query.Include(includeProperty);
}
return query.FirstOrDefault();
}
public virtual IEnumerable<T> GetItems(Expression<Func<T, bool>>? filter = null,
int index = 0, int count = 10,
params string[] includeProperties)
=> GetItems(filter, null, index, count, includeProperties);
public virtual IEnumerable<T> GetItems(Func<IQueryable<T>, IOrderedQueryable<T>>? orderBy = null,
int index = 0, int count = 10,
params string[] includeProperties)
=> GetItems(null, orderBy, index, count, includeProperties);
public virtual IEnumerable<T> GetItems(int index = 0, int count = 10,
params string[] includeProperties)
=> GetItems(null, null, index, count, includeProperties);
public virtual IEnumerable<T> GetItems(Expression<Func<T, bool>>? filter = null,
Func<IQueryable<T>, IOrderedQueryable<T>>? orderBy = null,
int index = 0, int count = 10,
params string[] includeProperties)
{
IQueryable<T> query = Set;
if (filter != null)
{
query = query.Where(filter);
}
foreach (string includeProperty in includeProperties)
{
query = query.Include(includeProperty);
}
if (orderBy != null)
{
query = orderBy(query);
}
return query.Skip(index * count)
.Take(count)
.ToList();
}
public virtual void Insert(T entity)
{
if (Set.Entry(entity).IsKeySet)
return;
Set.Add(entity);
}
public virtual void Insert(params T[] entities)
{
foreach (var entity in entities)
{
Insert(entity);
}
}
public virtual void Delete(object id)
{
T? entity = Set.Find(id);
if (entity == null) return;
Delete(entity);
}
public virtual void Delete(T entity)
{
if (Context.Entry(entity).State == EntityState.Detached)
{
Set.Attach(entity);
}
Set.Remove(entity);
}
public virtual void Update(T entity)
{
Set.Attach(entity);
Context.Entry(entity).State = EntityState.Modified;
}
public virtual int Count()
{
return Set.Count();
}
}
}

@ -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<Admin> admins { get; set; }
//public DbSet<Admin> admins { get; set; }
public DbSet<Character> characters { get; set; }
public DbSet<Commentary> comments { get; set; }
public DbSet<DailyQuote> dailyquotes { get; set; }
@ -18,14 +19,76 @@ namespace Contextlib
public DbSet<Images> images { get; set; }
public DbSet<Question> question { get; set; }
public DbSet<Quiz> quizzes { get; set; }
public DbSet<QuizQuestion> quizQuestions { get; set; }
//public DbSet<QuizQuestion> quizQuestions { get; set; }
public DbSet<Quote> quotes { get; set; }
//public DbSet<RecordQuiz> records { get; set; }
public DbSet<Source> sources { get; set; }
public DbSet<Users> users { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Users>()
.HasMany(q => q.Favorite)
.WithMany(u => u.Favorite)
.UsingEntity<Favorite>(
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<Users>()
.HasMany(u => u.Quotes)
.WithOne(q => q.User)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasForeignKey(q => q.IdUsersPropose);
modelBuilder.Entity<Users>()
.HasMany<Quote>()
.WithMany()
.UsingEntity<Commentary>(
i => i.HasKey(e => new { e.IdUser, e.IdQuote })
);
modelBuilder.Entity<Commentary>()
.HasOne(c => c.User)
.WithMany()
.HasForeignKey(c => c.IdUser);
modelBuilder.Entity<Quote>()
.HasMany(q => q.Commentarys)
.WithOne(c => c.Quote)
.OnDelete(DeleteBehavior.ClientCascade)
.HasForeignKey(c => c.IdQuote);
modelBuilder.Entity<Quiz>()
.HasMany(q => q.Questions)
.WithMany(u => u.Quizs)
.UsingEntity<QuizQuestion>(
l => l.HasOne<Question>().WithMany().HasForeignKey(q => q.IdQuestion),
r => r.HasOne<Quiz>().WithMany().HasForeignKey(u => u.IdQuiz)
);
}
public WTFContext()
{ }
public WTFContext(DbContextOptions<WTFContext> 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;");
}
}
}
}

@ -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!;
}
}

@ -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; }
}
}

@ -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,9 @@ namespace Entity
[StringLength(1)]
public string CorrectAnswer { get; set; }
public ICollection<Quiz> Quizs { get; } = new List<Quiz>();
[Required]
public bool IsValid { get; set; }
public ICollection<Quiz> Quizs { get; set; } = new List<Quiz>();
}
}

@ -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!;
}
}

@ -15,7 +15,7 @@ namespace Entity
public int Id { get; set; }
[Required]
[StringLength(50)]
[StringLength(100)]
public string Content { get; set; }
[Required]
@ -35,9 +35,16 @@ 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 lentité principale/parente, ou quand lentité principale/parente existe toujours mais que lentité 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 Users? User { get; set; } = null!;
@ -47,8 +54,8 @@ namespace Entity
public ICollection<DailyQuote> DailyQuotes { get; set; } = new List<DailyQuote>();
public ICollection<Commentary> commentaries { get; set; } = new List<Commentary>();
public ICollection<Commentary> Commentarys { get; set; } = new List<Commentary>();
public ICollection<Favorite> Favorite { get; set; } = new List<Favorite>();
public ICollection<Users> Favorite { get; } = new List<Users>();
}
}

@ -15,7 +15,7 @@ namespace Entity
public int Id { get; set; }
[Required]
[StringLength(50)]
[StringLength(100)]
public string Title { get; set; }
[Required]

@ -37,8 +37,6 @@ namespace Entity
public ICollection<Quote> Quotes { get; set; } = new List<Quote>();
public ICollection<Commentary> Commentary { get; set; } = new List<Commentary>();
public ICollection<Favorite> Favorite { get; set; } = new List<Favorite>();
public ICollection<Quote> Favorite { get; set; } = new List<Quote>();
}
}

@ -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<int> LastCommentId();

@ -10,7 +10,7 @@ namespace Shared
{
// Retrieves an image by its unique identifier (id).
// 'id' is the unique identifier of the image.
Task<TImage> GetImageById(string id);
Task<TImage> GetImageById(int id);
// Retrieves all images, with pagination support.
// This returns a list of all images in the system.

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shared
{
public class Mapper<T,U> where T : class
where U : class
{
readonly HashSet<Tuple<T, U>> mapper = new HashSet<Tuple<T, U>>();
public bool AddMapping(T t, U u)
{
var mapping = new Tuple<T, U>(t, u);
if (mapper.Contains(mapping)) return false;
mapper.Add(mapping);
return true;
}
public T? GetT(U u)
{
var result = mapper.Where(tuple => ReferenceEquals(tuple.Item2, u));
if (result.Count() != 1)
{
return null;
}
return result.First().Item1;
}
public U? GetU(T t)
{
var result = mapper.Where(tuple => ReferenceEquals(tuple.Item1, t));
if (result.Count() != 1)
{
return null;
}
return result.First().Item2;
}
public void Reset()
{
mapper.Clear();
}
}
}

@ -1,205 +0,0 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Character");
});
modelBuilder.Entity("Entity.Images", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ImgPath")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Images");
});
modelBuilder.Entity("Entity.Question", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AnswerA")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerB")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerC")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerD")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("CorrectAnswer")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Question");
});
modelBuilder.Entity("Entity.Quiz", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("NbQuestion")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Quiz");
});
modelBuilder.Entity("Entity.Quote", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsValid")
.HasColumnType("bit");
b.Property<int>("Langage")
.HasColumnType("int");
b.Property<int>("Likes")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Quote");
});
modelBuilder.Entity("Entity.Source", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Year")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Source");
});
modelBuilder.Entity("Entity.Users", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("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
}
}
}

@ -1,149 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace StubbedContextLib.Migrations
{
/// <inheritdoc />
public partial class myFirstMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Character",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Character", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Images",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ImgPath = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Images", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Question",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Text = table.Column<string>(type: "nvarchar(max)", nullable: false),
AnswerA = table.Column<string>(type: "nvarchar(max)", nullable: false),
AnswerB = table.Column<string>(type: "nvarchar(max)", nullable: false),
AnswerC = table.Column<string>(type: "nvarchar(max)", nullable: false),
AnswerD = table.Column<string>(type: "nvarchar(max)", nullable: false),
CorrectAnswer = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Question", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Quiz",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
NbQuestion = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Quiz", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Quote",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Content = table.Column<string>(type: "nvarchar(max)", nullable: false),
Likes = table.Column<int>(type: "int", nullable: false),
Langage = table.Column<int>(type: "int", nullable: false),
IsValid = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Quote", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Source",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Year = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Source", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
Created = table.Column<DateTime>(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" });
}
/// <inheritdoc />
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");
}
}
}

@ -1,248 +0,0 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Character");
});
modelBuilder.Entity("Entity.Images", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AnswerA")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerB")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerC")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("AnswerD")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("CorrectAnswer")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Question");
});
modelBuilder.Entity("Entity.Quiz", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("NbQuestion")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Quiz");
});
modelBuilder.Entity("Entity.Quote", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsValid")
.HasColumnType("bit");
b.Property<int>("Langage")
.HasColumnType("int");
b.Property<int>("Likes")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Quote");
});
modelBuilder.Entity("Entity.Source", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Year")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Source");
});
modelBuilder.Entity("Entity.Users", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("IdImage")
.HasColumnType("int");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("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
}
}
}

@ -1,89 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace StubbedContextLib.Migrations
{
/// <inheritdoc />
public partial class migr2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
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);
}
/// <inheritdoc />
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");
}
}
}

@ -0,0 +1,492 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace StubbedContextLib.Migrations
{
/// <inheritdoc />
public partial class migrationTest1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "images",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ImgPath = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_images", x => x.Id);
});
migrationBuilder.CreateTable(
name: "question",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Text = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
AnswerA = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
AnswerB = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
AnswerC = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
AnswerD = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
CorrectAnswer = table.Column<string>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Year = table.Column<int>(type: "int", nullable: false),
TypeSrc = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_sources", x => x.Id);
});
migrationBuilder.CreateTable(
name: "characters",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
IdImage = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_characters", x => x.Id);
table.ForeignKey(
name: "FK_characters_images_IdImage",
column: x => x.IdImage,
principalTable: "images",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "quizzes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
IdImage = table.Column<int>(type: "int", nullable: false),
NbQuestion = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_quizzes", x => x.Id);
table.ForeignKey(
name: "FK_quizzes_images_IdImage",
column: x => x.IdImage,
principalTable: "images",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Email = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Password = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
IdImage = table.Column<int>(type: "int", nullable: false),
Created = table.Column<DateTime>(type: "date", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_users", x => x.Id);
table.ForeignKey(
name: "FK_users_images_IdImage",
column: x => x.IdImage,
principalTable: "images",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "QuizQuestion",
columns: table => new
{
IdQuiz = table.Column<int>(type: "int", nullable: false),
IdQuestion = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_QuizQuestion", x => new { x.IdQuestion, x.IdQuiz });
table.ForeignKey(
name: "FK_QuizQuestion_question_IdQuestion",
column: x => x.IdQuestion,
principalTable: "question",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_QuizQuestion_quizzes_IdQuiz",
column: x => x.IdQuiz,
principalTable: "quizzes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "quotes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Content = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Likes = table.Column<int>(type: "int", nullable: false),
Langage = table.Column<int>(type: "int", nullable: false),
IsValid = table.Column<bool>(type: "bit", nullable: false),
IdCharacter = table.Column<int>(type: "int", nullable: false),
IdSource = table.Column<int>(type: "int", nullable: false),
IdUsersPropose = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_quotes", x => x.Id);
table.ForeignKey(
name: "FK_quotes_characters_IdCharacter",
column: x => x.IdCharacter,
principalTable: "characters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_quotes_sources_IdSource",
column: x => x.IdSource,
principalTable: "sources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_quotes_users_IdUsersPropose",
column: x => x.IdUsersPropose,
principalTable: "users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "comments",
columns: table => new
{
IdUser = table.Column<int>(type: "int", nullable: false),
IdQuote = table.Column<int>(type: "int", nullable: false),
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DateCommentary = table.Column<DateTime>(type: "date", nullable: false),
Comment = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_comments", x => new { x.IdUser, x.IdQuote });
table.ForeignKey(
name: "FK_comments_quotes_IdQuote",
column: x => x.IdQuote,
principalTable: "quotes",
principalColumn: "Id");
table.ForeignKey(
name: "FK_comments_users_IdUser",
column: x => x.IdUser,
principalTable: "users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "dailyquotes",
columns: table => new
{
IdQuote = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_dailyquotes", x => x.IdQuote);
table.ForeignKey(
name: "FK_dailyquotes_quotes_IdQuote",
column: x => x.IdQuote,
principalTable: "quotes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "favorites",
columns: table => new
{
IdUsers = table.Column<int>(type: "int", nullable: false),
IdQuote = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_favorites", x => new { x.IdQuote, x.IdUsers });
table.ForeignKey(
name: "FK_favorites_quotes_IdQuote",
column: x => x.IdQuote,
principalTable: "quotes",
principalColumn: "Id");
table.ForeignKey(
name: "FK_favorites_users_IdUsers",
column: x => x.IdUsers,
principalTable: "users",
principalColumn: "Id");
});
migrationBuilder.InsertData(
table: "images",
columns: new[] { "Id", "ImgPath" },
values: new object[,]
{
{ 1, "https://th.bing.com/th/id/OIP.TJuWNCsibz8MVmhdNQEdMwHaE8?w=244&h=180&c=7&r=0&o=5&pid=1.7" },
{ 2, "https://th.bing.com/th/id/OIP.NgXRQ5-IknA6_qOPFhLWIwHaHK?w=165&h=180&c=7&r=0&o=5&pid=1.7" },
{ 3, "https://th.bing.com/th/id/OIP.XcJoJ6bC9sAMjol1pJn5UQHaLH?w=118&h=180&c=7&r=0&o=5&pid=1.7" },
{ 4, "https://th.bing.com/th/id/OIP.PPIESqZaNDa-qUcfSDXhdQHaGK?w=210&h=180&c=7&r=0&o=5&pid=1.7" },
{ 5, "https://th.bing.com/th/id/OIP.XBghSl2kfRNNtQoSxc901wHaHa?w=177&h=180&c=7&r=0&o=5&pid=1.7" },
{ 6, "https://th.bing.com/th/id/OIP.af1Aid64cqEKoIOBgCPxtQHaJO?w=145&h=182&c=7&r=0&o=5&pid=1.7" },
{ 7, "https://th.bing.com/th/id/OIP.ri5vSXr5lNTLt4DO6KQXyQHaI4?w=158&h=189&c=7&r=0&o=5&pid=1.7" },
{ 8, "https://th.bing.com/th/id/OIP.uPTRLR8uspCiafiunUqKfQHaMJ?w=115&h=180&c=7&r=0&o=5&pid=1.7" },
{ 9, "https://th.bing.com/th/id/OIP.hcJis4rKbyQtugsoFJU2ngHaM_?w=118&h=207&c=7&r=0&o=5&pid=1.7" },
{ 10, "https://th.bing.com/th/id/OIP.Py1_XfUrKJY_A6tYEmFS5wHaE8?w=280&h=187&c=7&r=0&o=5&pid=1.7" }
});
migrationBuilder.InsertData(
table: "question",
columns: new[] { "Id", "AnswerA", "AnswerB", "AnswerC", "AnswerD", "CorrectAnswer", "Text" },
values: new object[,]
{
{ 1, "Gimli", "Aragorn", "Frodon", "Gandalf", "B", "Qui est le leader de la Communauté de l'Anneau ?" },
{ 2, "Serdaigle", "Gryffondor", "Serpentard", "Poufsouffle", "B", "Dans quelle maison Harry Potter est-il ?" },
{ 3, "Saroumane", "Sauron", "Gollum", "Gothmog", "B", "Qui est le Seigneur des Ténèbres dans la saga Le Seigneur des Anneaux ?" },
{ 4, "Han Solo", "Princesse Leia", "Chewbacca", "R2-D2", "A", "Dans le film Star Wars : Episode IV, qui sauve Luke Skywalker de l'Étoile de la Mort ?" },
{ 5, "Reine Jadis", "Aslan", "Edmund", "Lucy", "B", "Qui est le souverain de Narnia dans Le Lion, la Sorcière Blanche et l'Armoire Magique ?" },
{ 6, "Smaug", "Falkor", "Norbert", "Shenron", "A", "Quel est le nom du dragon dans Le Hobbit ?" },
{ 7, "Bella Swan", "Edward Cullen", "Jacob Black", "Victoria", "A", "Qui est la première personne à être mordue par un vampire dans Twilight ?" },
{ 8, "Obi-Wan Kenobi", "Yoda", "Han Solo", "Luke Skywalker", "A", "Quel personnage dit Que la Force soit avec toi dans Star Wars ?" },
{ 9, "Dr. Ellie Sattler", "Alan Grant", "John Hammond", "Dennis Nedry", "B", "Dans Jurassic Park, quel est le nom du paléontologue sur l'île ?" },
{ 10, "Cersei Lannister", "Arya Stark", "Daenerys Targaryen", "Sansa Stark", "C", "Dans Game of Thrones, qui est surnommée la Mère des Dragons ?" }
});
migrationBuilder.InsertData(
table: "sources",
columns: new[] { "Id", "Title", "TypeSrc", "Year" },
values: new object[,]
{
{ 1, "Jurassic Park", 0, 1993 },
{ 2, "Le Seigneur des anneaux : La Communauté de l'anneau", 0, 2001 },
{ 3, "Game of throne", 1, 2011 },
{ 4, "Harry Potter à l'école des sorcier", 0, 1997 },
{ 5, "Star Wars, épisode IV : Un nouvel espoir", 0, 1977 }
});
migrationBuilder.InsertData(
table: "characters",
columns: new[] { "Id", "IdImage", "Name" },
values: new object[,]
{
{ 1, 1, "Alan Grant" },
{ 2, 2, "Aragorn" },
{ 3, 3, "Legolas" },
{ 4, 4, "Frodon" },
{ 5, 5, "Dobby" },
{ 6, 6, "Jon Snow" },
{ 7, 7, "Daenerys Targaryen" },
{ 8, 8, "Luke Skywalker" },
{ 9, 9, "Princess Leia" },
{ 10, 10, "Harry Potter" }
});
migrationBuilder.InsertData(
table: "quizzes",
columns: new[] { "Id", "IdImage", "NbQuestion", "Title" },
values: new object[,]
{
{ 1, 1, 5, "Quiz 1" },
{ 2, 2, 5, "Quiz 2" }
});
migrationBuilder.InsertData(
table: "users",
columns: new[] { "Id", "Created", "Email", "IdImage", "Password", "UserName" },
values: new object[,]
{
{ 1, new DateTime(2025, 5, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), "jhonDhoe@gmail.com", 1, "1234", "Jhon-Dhoe" },
{ 2, new DateTime(2025, 3, 19, 0, 0, 0, 0, DateTimeKind.Unspecified), "lucy_rose@outlook.com", 2, "abcd", "Lucy-Rose" },
{ 3, new DateTime(2024, 11, 2, 0, 0, 0, 0, DateTimeKind.Unspecified), "mark.taylor@yahoo.com", 3, "5678", "Mark-Taylor" },
{ 4, new DateTime(2025, 2, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), "sophie.martin@gmail.com", 4, "4321", "Sophie-Martin" },
{ 5, new DateTime(2025, 1, 15, 0, 0, 0, 0, DateTimeKind.Unspecified), "nathan_doe@aol.com", 5, "8765", "Nathan-Doe" },
{ 6, new DateTime(2025, 4, 7, 0, 0, 0, 0, DateTimeKind.Unspecified), "ella.brown@icloud.com", 6, "2468", "Ella-Brown" },
{ 7, new DateTime(2024, 12, 25, 0, 0, 0, 0, DateTimeKind.Unspecified), "oliver_smith@gmail.com", 7, "1357", "Oliver-Smith" },
{ 8, new DateTime(2025, 3, 5, 0, 0, 0, 0, DateTimeKind.Unspecified), "mia.jones@outlook.com", 8, "1122", "Mia-Jones" },
{ 9, new DateTime(2025, 2, 22, 0, 0, 0, 0, DateTimeKind.Unspecified), "kevin_williams@aol.com", 9, "2233", "Kevin-Williams" },
{ 10, new DateTime(2025, 1, 3, 0, 0, 0, 0, DateTimeKind.Unspecified), "olivia.white@yahoo.com", 10, "3344", "Olivia-White" }
});
migrationBuilder.InsertData(
table: "QuizQuestion",
columns: new[] { "IdQuestion", "IdQuiz" },
values: new object[,]
{
{ 1, 1 },
{ 2, 1 },
{ 3, 1 },
{ 4, 1 },
{ 5, 1 },
{ 6, 2 },
{ 7, 2 },
{ 8, 2 },
{ 9, 2 },
{ 10, 2 }
});
migrationBuilder.InsertData(
table: "quotes",
columns: new[] { "Id", "Content", "IdCharacter", "IdSource", "IdUsersPropose", "IsValid", "Langage", "Likes" },
values: new object[,]
{
{ 1, "Je n'y crois pas. Je n'y crois pas. Ce n'est pas possible", 1, 1, 1, true, 1, 11025 },
{ 2, "There is always hope", 2, 2, 1, true, 0, 11025 },
{ 3, "A red sun rises. Blood has been spilled this night.", 3, 2, 1, true, 0, 11025 },
{ 4, "I wish the Ring had never come to me.I wish none of this had happened.", 4, 2, 1, true, 0, 11025 },
{ 5, "Dobby is a free elf!", 5, 4, 1, true, 0, 11025 },
{ 6, "Winter is comming", 6, 3, 1, true, 0, 11025 },
{ 7, "Je suis la dernière Targaryen. Je suis la reine des dragons", 7, 3, 1, true, 1, 11025 },
{ 8, "Je ne suis pas prêt à affronter ça. C'est trop pour moi.", 8, 5, 1, true, 1, 11025 },
{ 9, "Aidez-moi, Obi-Wan Kenobi, vous êtes mon seul espoir.", 9, 5, 1, true, 1, 11025 },
{ 10, "La quoi ?", 10, 4, 1, true, 1, 11025 }
});
migrationBuilder.InsertData(
table: "comments",
columns: new[] { "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 }
});
migrationBuilder.InsertData(
table: "dailyquotes",
column: "IdQuote",
values: new object[]
{
1,
5
});
migrationBuilder.InsertData(
table: "favorites",
columns: new[] { "IdQuote", "IdUsers" },
values: new object[,]
{
{ 1, 6 },
{ 2, 8 },
{ 3, 2 },
{ 4, 10 },
{ 5, 3 },
{ 6, 7 },
{ 8, 9 },
{ 9, 1 },
{ 10, 5 }
});
migrationBuilder.CreateIndex(
name: "IX_characters_IdImage",
table: "characters",
column: "IdImage");
migrationBuilder.CreateIndex(
name: "IX_comments_IdQuote",
table: "comments",
column: "IdQuote");
migrationBuilder.CreateIndex(
name: "IX_favorites_IdUsers",
table: "favorites",
column: "IdUsers");
migrationBuilder.CreateIndex(
name: "IX_QuizQuestion_IdQuiz",
table: "QuizQuestion",
column: "IdQuiz");
migrationBuilder.CreateIndex(
name: "IX_quizzes_IdImage",
table: "quizzes",
column: "IdImage");
migrationBuilder.CreateIndex(
name: "IX_quotes_IdCharacter",
table: "quotes",
column: "IdCharacter");
migrationBuilder.CreateIndex(
name: "IX_quotes_IdSource",
table: "quotes",
column: "IdSource");
migrationBuilder.CreateIndex(
name: "IX_quotes_IdUsersPropose",
table: "quotes",
column: "IdUsersPropose");
migrationBuilder.CreateIndex(
name: "IX_users_IdImage",
table: "users",
column: "IdImage");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "comments");
migrationBuilder.DropTable(
name: "dailyquotes");
migrationBuilder.DropTable(
name: "favorites");
migrationBuilder.DropTable(
name: "QuizQuestion");
migrationBuilder.DropTable(
name: "quotes");
migrationBuilder.DropTable(
name: "question");
migrationBuilder.DropTable(
name: "quizzes");
migrationBuilder.DropTable(
name: "characters");
migrationBuilder.DropTable(
name: "sources");
migrationBuilder.DropTable(
name: "users");
migrationBuilder.DropTable(
name: "images");
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace StubbedContextLib.Migrations
{
/// <inheritdoc />
public partial class migr1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Contextlib;
using Entity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
namespace StubbedContextLib
{
@ -15,8 +16,34 @@ namespace StubbedContextLib
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Admin>().HasData(
/*modelBuilder.Entity<Admin>().HasData(
new Admin() { IdUsers = 1 }
);*/
modelBuilder.Entity<Images>().HasData(
new Images() { Id = 1, ImgPath = "https://th.bing.com/th/id/OIP.TJuWNCsibz8MVmhdNQEdMwHaE8?w=244&h=180&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 2, ImgPath = "https://th.bing.com/th/id/OIP.NgXRQ5-IknA6_qOPFhLWIwHaHK?w=165&h=180&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 3, ImgPath = "https://th.bing.com/th/id/OIP.XcJoJ6bC9sAMjol1pJn5UQHaLH?w=118&h=180&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 4, ImgPath = "https://th.bing.com/th/id/OIP.PPIESqZaNDa-qUcfSDXhdQHaGK?w=210&h=180&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 5, ImgPath = "https://th.bing.com/th/id/OIP.XBghSl2kfRNNtQoSxc901wHaHa?w=177&h=180&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 6, ImgPath = "https://th.bing.com/th/id/OIP.af1Aid64cqEKoIOBgCPxtQHaJO?w=145&h=182&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 7, ImgPath = "https://th.bing.com/th/id/OIP.ri5vSXr5lNTLt4DO6KQXyQHaI4?w=158&h=189&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 8, ImgPath = "https://th.bing.com/th/id/OIP.uPTRLR8uspCiafiunUqKfQHaMJ?w=115&h=180&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 9, ImgPath = "https://th.bing.com/th/id/OIP.hcJis4rKbyQtugsoFJU2ngHaM_?w=118&h=207&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 10, ImgPath = "https://th.bing.com/th/id/OIP.Py1_XfUrKJY_A6tYEmFS5wHaE8?w=280&h=187&c=7&r=0&o=5&pid=1.7" }
);
modelBuilder.Entity<Users>().HasData(
new Users() { Id = 1, Email = "jhonDhoe@gmail.com", Password = "1234", Created = new DateTime(2025, 5, 12), UserName = "Jhon-Dhoe", IdImage = 1 },
new Users() { Id = 2, Email = "lucy_rose@outlook.com", Password = "abcd", Created = new DateTime(2025, 3, 19), UserName = "Lucy-Rose", IdImage = 2 },
new Users() { Id = 3, Email = "mark.taylor@yahoo.com", Password = "5678", Created = new DateTime(2024, 11, 2), UserName = "Mark-Taylor", IdImage = 3 },
new Users() { Id = 4, Email = "sophie.martin@gmail.com", Password = "4321", Created = new DateTime(2025, 2, 28), UserName = "Sophie-Martin", IdImage = 4 },
new Users() { Id = 5, Email = "nathan_doe@aol.com", Password = "8765", Created = new DateTime(2025, 1, 15), UserName = "Nathan-Doe", IdImage = 5 },
new Users() { Id = 6, Email = "ella.brown@icloud.com", Password = "2468", Created = new DateTime(2025, 4, 7), UserName = "Ella-Brown", IdImage = 6 },
new Users() { Id = 7, Email = "oliver_smith@gmail.com", Password = "1357", Created = new DateTime(2024, 12, 25), UserName = "Oliver-Smith", IdImage = 7 },
new Users() { Id = 8, Email = "mia.jones@outlook.com", Password = "1122", Created = new DateTime(2025, 3, 5), UserName = "Mia-Jones", IdImage = 8 },
new Users() { Id = 9, Email = "kevin_williams@aol.com", Password = "2233", Created = new DateTime(2025, 2, 22), UserName = "Kevin-Williams", IdImage = 9 },
new Users() { Id = 10, Email = "olivia.white@yahoo.com", Password = "3344", Created = new DateTime(2025, 1, 3), UserName = "Olivia-White", IdImage = 10 }
);
modelBuilder.Entity<Character>().HasData(
@ -32,9 +59,22 @@ namespace StubbedContextLib
new Character() { Id = 10, Name = "Harry Potter", IdImage = 10 }
);
modelBuilder.Entity<Quote>().HasData(
new Quote() { Id = 1, Content = "Je n'y crois pas. Je n'y crois pas. Ce n'est pas possible", IdCharacter = 1, IdSource = 1, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 },
new Quote() { Id = 2, Content = "There is always hope", IdCharacter = 2, IdSource = 2, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 },
new Quote() { Id = 3, Content = "A red sun rises. Blood has been spilled this night.", IdCharacter = 3, IdSource = 2, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 },
new Quote() { Id = 4, Content = "I wish the Ring had never come to me.I wish none of this had happened.", IdCharacter = 4, IdSource = 2, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 },
new Quote() { Id = 5, Content = "Dobby is a free elf!", IdCharacter = 5, IdSource = 4, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 },
new Quote() { Id = 6, Content = "Winter is comming", IdCharacter = 6, IdSource = 3, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 },
new Quote() { Id = 7, Content = "Je suis la dernière Targaryen. Je suis la reine des dragons", IdCharacter = 7, IdSource = 3, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 },
new Quote() { Id = 8, Content = "Je ne suis pas prêt à affronter ça. C'est trop pour moi.", IdCharacter = 8, IdSource = 5, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 },
new Quote() { Id = 9, Content = "Aidez-moi, Obi-Wan Kenobi, vous êtes mon seul espoir.", IdCharacter = 9, IdSource = 5, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 },
new Quote() { Id = 10, Content = "La quoi ?", IdCharacter = 10, IdSource = 4, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 }
);
modelBuilder.Entity<Commentary>().HasData(
new Commentary() { Id = 1, Comment = "Ce film est le meilleur", DateCommentary = new DateTime(2025,2,3), IdQuote = 1, IdUsers = 2 },
new Commentary() { Id = 2, Comment = "Very good", DateCommentary = new DateTime(2025, 3, 11), IdQuote = 1, IdUsers = 3 }
new Commentary() { Id = 1, Comment = "Ce film est le meilleur", DateCommentary = new DateTime(2025,2,3), IdQuote = 1, IdUser = 2 },
new Commentary() { Id = 2, Comment = "Very good", DateCommentary = new DateTime(2025, 3, 11), IdQuote = 1, IdUser = 3 }
);
modelBuilder.Entity<DailyQuote>().HasData(
@ -54,35 +94,24 @@ namespace StubbedContextLib
new Favorite() { IdQuote = 10, IdUsers = 5 }
);
modelBuilder.Entity<Images>().HasData(
new Images() { Id = 1 , ImgPath = "https://th.bing.com/th/id/OIP.TJuWNCsibz8MVmhdNQEdMwHaE8?w=244&h=180&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 2 , ImgPath = "https://th.bing.com/th/id/OIP.NgXRQ5-IknA6_qOPFhLWIwHaHK?w=165&h=180&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 3 , ImgPath = "https://th.bing.com/th/id/OIP.XcJoJ6bC9sAMjol1pJn5UQHaLH?w=118&h=180&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 4 , ImgPath = "https://th.bing.com/th/id/OIP.PPIESqZaNDa-qUcfSDXhdQHaGK?w=210&h=180&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 5 , ImgPath = "https://th.bing.com/th/id/OIP.XBghSl2kfRNNtQoSxc901wHaHa?w=177&h=180&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 6 , ImgPath = "https://th.bing.com/th/id/OIP.af1Aid64cqEKoIOBgCPxtQHaJO?w=145&h=182&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 7 , ImgPath = "https://th.bing.com/th/id/OIP.ri5vSXr5lNTLt4DO6KQXyQHaI4?w=158&h=189&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 8 , ImgPath = "https://th.bing.com/th/id/OIP.uPTRLR8uspCiafiunUqKfQHaMJ?w=115&h=180&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 9 , ImgPath = "https://th.bing.com/th/id/OIP.hcJis4rKbyQtugsoFJU2ngHaM_?w=118&h=207&c=7&r=0&o=5&pid=1.7" },
new Images() { Id = 10 , ImgPath = "https://th.bing.com/th/id/OIP.Py1_XfUrKJY_A6tYEmFS5wHaE8?w=280&h=187&c=7&r=0&o=5&pid=1.7" }
);
modelBuilder.Entity<Question>().HasData(
new Question() { Id = 1, Text = "Qui est le leader de la Communauté de l'Anneau ?", AnswerA = "Gimli", AnswerB = "Aragorn", AnswerC = "Frodon", AnswerD = "Gandalf", CorrectAnswer = "B" },
new Question() { Id = 1, Text = "Qui est le leader de la Communauté de l'Anneau ?", AnswerA = "Gimli", AnswerB = "Aragorn", AnswerC = "Frodon", AnswerD = "Gandalf", CorrectAnswer = "B", IsValid = true },
new Question() { Id = 2, Text = "Dans quelle maison Harry Potter est-il ?", AnswerA = "Serdaigle", AnswerB = "Gryffondor", AnswerC = "Serpentard", AnswerD = "Poufsouffle", CorrectAnswer = "B" },
new Question() { Id = 3, Text = "Qui est le Seigneur des Ténèbres dans la saga 'Le Seigneur des Anneaux' ?", AnswerA = "Saroumane", AnswerB = "Sauron", AnswerC = "Gollum", AnswerD = "Gothmog", CorrectAnswer = "B" },
new Question() { Id = 4, Text = "Dans le film 'Star Wars : Episode IV', qui sauve Luke Skywalker de l'Étoile de la Mort ?", AnswerA = "Han Solo", AnswerB = "Princesse Leia", AnswerC = "Chewbacca", AnswerD = "R2-D2", CorrectAnswer = "A" },
new Question() { Id = 5, Text = "Qui est le souverain de Narnia dans 'Le Lion, la Sorcière Blanche et l'Armoire Magique' ?", AnswerA = "Reine Jadis", AnswerB = "Aslan", AnswerC = "Edmund", AnswerD = "Lucy", CorrectAnswer = "B" },
new Question() { Id = 6, Text = "Quel est le nom du dragon dans 'Le Hobbit' ?", AnswerA = "Smaug", AnswerB = "Falkor", AnswerC = "Norbert", AnswerD = "Shenron", CorrectAnswer = "A" },
new Question() { Id = 7, Text = "Qui est la première personne à être mordue par un vampire dans 'Twilight' ?", AnswerA = "Bella Swan", AnswerB = "Edward Cullen", AnswerC = "Jacob Black", AnswerD = "Victoria", CorrectAnswer = "A" },
new Question() { Id = 8, Text = "Quel personnage dit 'Que la Force soit avec toi' dans 'Star Wars' ?", AnswerA = "Obi-Wan Kenobi", AnswerB = "Yoda", AnswerC = "Han Solo", AnswerD = "Luke Skywalker", CorrectAnswer = "A" },
new Question() { Id = 9, Text = "Dans 'Jurassic Park', quel est le nom du paléontologue sur l'île ?", AnswerA = "Dr. Ellie Sattler", AnswerB = "Alan Grant", AnswerC = "John Hammond", AnswerD = "Dennis Nedry", CorrectAnswer = "B" },
new Question() { Id = 10, Text = "Dans 'Game of Thrones', qui est surnommée la Mère des Dragons ?", AnswerA = "Cersei Lannister", AnswerB = "Arya Stark", AnswerC = "Daenerys Targaryen", AnswerD = "Sansa Stark", CorrectAnswer = "C" }
new Question() { Id = 3, Text = "Qui est le Seigneur des Ténèbres dans la saga Le Seigneur des Anneaux ?", AnswerA = "Saroumane", AnswerB = "Sauron", AnswerC = "Gollum", AnswerD = "Gothmog", CorrectAnswer = "B", IsValid = true },
new Question() { Id = 4, Text = "Dans le film Star Wars : Episode IV, qui sauve Luke Skywalker de l'Étoile de la Mort ?", AnswerA = "Han Solo", AnswerB = "Princesse Leia", AnswerC = "Chewbacca", AnswerD = "R2-D2", CorrectAnswer = "A", IsValid = true },
new Question() { Id = 5, Text = "Qui est le souverain de Narnia dans Le Lion, la Sorcière Blanche et l'Armoire Magique ?", AnswerA = "Reine Jadis", AnswerB = "Aslan", AnswerC = "Edmund", AnswerD = "Lucy", CorrectAnswer = "B", IsValid = true },
new Question() { Id = 6, Text = "Quel est le nom du dragon dans Le Hobbit ?", AnswerA = "Smaug", AnswerB = "Falkor", AnswerC = "Norbert", AnswerD = "Shenron", CorrectAnswer = "A", IsValid = true },
new Question() { Id = 7, Text = "Qui est la première personne à être mordue par un vampire dans Twilight ?", AnswerA = "Bella Swan", AnswerB = "Edward Cullen", AnswerC = "Jacob Black", AnswerD = "Victoria", CorrectAnswer = "A", IsValid = true },
new Question() { Id = 8, Text = "Quel personnage dit Que la Force soit avec toi dans Star Wars ?", AnswerA = "Obi-Wan Kenobi", AnswerB = "Yoda", AnswerC = "Han Solo", AnswerD = "Luke Skywalker", CorrectAnswer = "A", IsValid = true },
new Question() { Id = 9, Text = "Dans Jurassic Park, quel est le nom du paléontologue sur l'île ?", AnswerA = "Dr. Ellie Sattler", AnswerB = "Alan Grant", AnswerC = "John Hammond", AnswerD = "Dennis Nedry", CorrectAnswer = "B", IsValid = true },
new Question() { Id = 10, Text = "Dans Game of Thrones, qui est surnommée la Mère des Dragons ?", AnswerA = "Cersei Lannister", AnswerB = "Arya Stark", AnswerC = "Daenerys Targaryen", AnswerD = "Sansa Stark", CorrectAnswer = "C", IsValid = true }
);
modelBuilder.Entity<Quiz>().HasData(
new Quiz() { Id = 1, IdImage = 1, Title = "Quiz 1", NbQuestion = 5 },
new Quiz() { Id = 1, IdImage = 2, Title = "Quiz 2", NbQuestion = 5 }
new Quiz() { Id = 2, IdImage = 2, Title = "Quiz 2", NbQuestion = 5 }
);
modelBuilder.Entity<QuizQuestion>().HasData(
@ -98,20 +127,6 @@ namespace StubbedContextLib
new QuizQuestion() { IdQuestion = 10, IdQuiz = 2 }
);
modelBuilder.Entity<Quote>().HasData(
new Quote() { Id = 1, Content = "Je n'y crois pas. Je n'y crois pas. Ce n'est pas possible", IdCharacter = 1, IdSource = 1, IdUsersPropose = 1 , IsValid = true, Langage = LangEnum.vf, Likes = 11025},
new Quote() { Id = 2, Content = "There is always hope", IdCharacter = 2, IdSource = 2, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 },
new Quote() { Id = 3, Content = "A red sun rises. Blood has been spilled this night.", IdCharacter = 3, IdSource = 2, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 },
new Quote() { Id = 4, Content = "I wish the Ring had never come to me.I wish none of this had happened.", IdCharacter = 4, IdSource = 2, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 },
new Quote() { Id = 5, Content = "Dobby is a free elf!", IdCharacter = 5 , IdSource = 4 , IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 },
new Quote() { Id = 6, Content = "Winter is comming", IdCharacter = 6 , IdSource = 3, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vo, Likes = 11025 },
new Quote() { Id = 7, Content = "Je suis la dernière Targaryen. Je suis la reine des dragons", IdCharacter = 7 , IdSource = 3, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 },
new Quote() { Id = 8, Content = "Je ne suis pas prêt à affronter ça. C'est trop pour moi.", IdCharacter = 8 , IdSource = 5, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 },
new Quote() { Id = 9, Content = "Aidez-moi, Obi-Wan Kenobi, vous êtes mon seul espoir.", IdCharacter = 9 , IdSource = 5, IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 },
new Quote() { Id = 10, Content = "La quoi ?", IdCharacter = 10 , IdSource = 4 , IdUsersPropose = 1, IsValid = true, Langage = LangEnum.vf, Likes = 11025 }
);
modelBuilder.Entity<Source>().HasData(
new Source() { Id = 1, Title = "Jurassic Park", TypeSrc = TypeSrcEnum.movie, Year = 1993 },
new Source() { Id = 2, Title = "Le Seigneur des anneaux : La Communauté de l'anneau", TypeSrc = TypeSrcEnum.movie, Year = 2001 },
@ -119,21 +134,21 @@ namespace StubbedContextLib
new Source() { Id = 4, Title = "Harry Potter à l'école des sorcier", TypeSrc = TypeSrcEnum.movie, Year = 1997 },
new Source() { Id = 5, Title = "Star Wars, épisode IV : Un nouvel espoir", TypeSrc = TypeSrcEnum.movie, Year = 1977 }
);
}
modelBuilder.Entity<Users>().HasData(
new Users() { Id = 1, Email = "jhonDhoe@gmail.com", Password = "1234", Created = new DateTime(2025, 5, 12), UserName = "Jhon-Dhoe", IdImage = 1 },
new Users() { Id = 2, Email = "lucy_rose@outlook.com", Password = "abcd", Created = new DateTime(2025, 3, 19), UserName = "Lucy-Rose", IdImage = 2 },
new Users() { Id = 3, Email = "mark.taylor@yahoo.com", Password = "5678", Created = new DateTime(2024, 11, 2), UserName = "Mark-Taylor", IdImage = 3 },
new Users() { Id = 4, Email = "sophie.martin@gmail.com", Password = "4321", Created = new DateTime(2025, 2, 28), UserName = "Sophie-Martin", IdImage = 4 },
new Users() { Id = 5, Email = "nathan_doe@aol.com", Password = "8765", Created = new DateTime(2025, 1, 15), UserName = "Nathan-Doe", IdImage = 5 },
new Users() { Id = 6, Email = "ella.brown@icloud.com", Password = "2468", Created = new DateTime(2025, 4, 7), UserName = "Ella-Brown", IdImage = 6 },
new Users() { Id = 7, Email = "oliver_smith@gmail.com", Password = "1357", Created = new DateTime(2024, 12, 25), UserName = "Oliver-Smith", IdImage = 7 },
new Users() { Id = 8, Email = "mia.jones@outlook.com", Password = "1122", Created = new DateTime(2025, 3, 5), UserName = "Mia-Jones", IdImage = 8 },
new Users() { Id = 9, Email = "kevin_williams@aol.com", Password = "2233", Created = new DateTime(2025, 2, 22), UserName = "Kevin-Williams", IdImage = 9 },
new Users() { Id = 10, Email = "olivia.white@yahoo.com", Password = "3344", Created = new DateTime(2025, 1, 3), UserName = "Olivia-White", IdImage = 10 }
);
public StubWTFContext()
{ }
public StubWTFContext(DbContextOptions<WTFContext> options)
: base(options)
{ }
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
if (!options.IsConfigured)
{
options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Wf-Database.mdf;Trusted_Connection=True;");
}
}
}
}

@ -0,0 +1,2 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -1,4 +1,4 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34723.18
@ -55,6 +55,10 @@ Global
{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CF20FAC-C2F1-4048-9D46-F39081B0FBEF}.Release|Any CPU.Build.0 = Release|Any CPU
{4A1CBA3D-C798-4E19-865F-39F919F1205A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A1CBA3D-C798-4E19-865F-39F919F1205A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A1CBA3D-C798-4E19-865F-39F919F1205A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A1CBA3D-C798-4E19-865F-39F919F1205A}.Release|Any CPU.Build.0 = Release|Any CPU
{48002CA2-7CFF-4077-90CF-392476320CE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48002CA2-7CFF-4077-90CF-392476320CE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48002CA2-7CFF-4077-90CF-392476320CE3}.Release|Any CPU.ActiveCfg = Release|Any CPU

@ -11,6 +11,7 @@
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="xunit" Version="2.5.3" />
@ -21,6 +22,7 @@
<ProjectReference Include="..\DTO\DTO.csproj" />
<ProjectReference Include="..\Shared\Shared.csproj" />
<ProjectReference Include="..\WfApi\WfApi.csproj" />
<ProjectReference Include="..\StubbedContextLib\StubbedContextLib.csproj" />
</ItemGroup>
<ItemGroup>

Loading…
Cancel
Save