diff --git a/.drone.yml b/.drone.yml
new file mode 100644
index 0000000..454daf2
--- /dev/null
+++ b/.drone.yml
@@ -0,0 +1,53 @@
+kind: pipeline
+type: docker
+name: CI
+
+trigger:
+ event:
+ - push
+
+steps:
+ - name: build
+ image: mcr.microsoft.com/dotnet/sdk:8.0
+ commands:
+ - cd Verax_API_EF
+ - cd Verax_API_EF
+ - dotnet restore Verax_API_EF.sln
+ - dotnet build Verax_API_EF.sln -c Release --no-restore
+ - dotnet publish Verax_API_EF.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release
+
+ - name: tests
+ image: mcr.microsoft.com/dotnet/sdk:8.0
+ commands:
+ - cd Verax_API_EF
+ - cd Verax_API_EF
+ - dotnet restore Verax_API_EF.sln
+ - dotnet test Verax_API_EF.sln --no-restore
+ depends_on: [build]
+
+ - name: code-inspection
+ image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet7
+ secrets: [ SECRET_SONAR_LOGIN ]
+ environment:
+ sonar_host: https://codefirst.iut.uca.fr/sonar/
+ sonar_token:
+ from_secret: SECRET_SONAR_LOGIN
+ project_key: Verax_API_EF
+ coverage_exclusions: "TestsUnitaires/**"
+ commands:
+ - cd Verax_API_EF/
+ - cd Verax_API_EF/
+ - dotnet restore Verax_API_EF.sln
+ - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token}
+ - dotnet build Verax_API_EF.sln -c Release --no-restore
+ - dotnet test Verax_API_EF.sln --logger trx --no-restore
+ - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport"
+ - dotnet publish Verax_API_EF.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release
+ - dotnet sonarscanner end /d:sonar.login=$${sonar_token}
+ when:
+ branch:
+ - master
+ event:
+ - push
+ - pull_request
+ depends_on: [build,tests]
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/.idea/.idea.Verax_API_EF/.idea/vcs.xml b/Verax_API_EF/Verax_API_EF/.idea/.idea.Verax_API_EF/.idea/vcs.xml
index 6c0b863..830a534 100644
--- a/Verax_API_EF/Verax_API_EF/.idea/.idea.Verax_API_EF/.idea/vcs.xml
+++ b/Verax_API_EF/Verax_API_EF/.idea/.idea.Verax_API_EF/.idea/vcs.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/API/API.csproj b/Verax_API_EF/Verax_API_EF/API/API.csproj
index 01ea7d9..1a9894b 100644
--- a/Verax_API_EF/Verax_API_EF/API/API.csproj
+++ b/Verax_API_EF/Verax_API_EF/API/API.csproj
@@ -21,11 +21,13 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
diff --git a/Verax_API_EF/Verax_API_EF/API/Controllers/ArticleController.cs b/Verax_API_EF/Verax_API_EF/API/Controllers/ArticleController.cs
index d83ebb8..77caa98 100644
--- a/Verax_API_EF/Verax_API_EF/API/Controllers/ArticleController.cs
+++ b/Verax_API_EF/Verax_API_EF/API/Controllers/ArticleController.cs
@@ -1,3 +1,4 @@
+using API_Mapping;
using API_Services;
using Microsoft.AspNetCore.Mvc;
using Model;
@@ -10,53 +11,117 @@ namespace API.Controllers
public class ArticleController : ControllerBase
{
- private readonly IArticleService _articleService;
+ //private readonly IArticleService _articleService;
+ private readonly IDataManager _dataManager;
+ private readonly ILogger _logger;
- public ArticleController(IArticleService articleService)
+ public ArticleController(IDataManager dataManager, ILogger logger)
{
- _articleService = articleService;
+ this._dataManager = dataManager;
+ this._logger = logger;
}
+ [Route("/articles")]
[HttpGet]
- public async Task GetAllArticles()
+ public async Task GetAllArticles([FromQuery] int index = 0, [FromQuery] int count = 10, [FromQuery] ArticleOrderCriteria orderCriterium = ArticleOrderCriteria.None)
{
- var result = await _articleService.GetAllArticles();
- if (result == null)
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(GetAllArticles), index, count, orderCriterium);
+ try
{
- return NotFound();
+ var result = (await _dataManager.ArticleService.GetAllArticles(index, count, orderCriterium)).Select(a => a.ToDTO());
+ if (result == null)
+ {
+ return NotFound();
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
}
- return Ok(result);
}
[HttpGet("/article/{id}")]
- public async Task GetArticleById(int id)
+ public async Task GetArticleById(int id)
{
- var result = await _articleService.GetArticleById(id);
- if (result == null)
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(GetArticleById), id);
+ try
+ {
+ var result = (await _dataManager.ArticleService.GetArticleById(id)).ToDTO();
+ if (result == null)
+ {
+ return NotFound($"Article ID {id} not found");
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
{
- return null;
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
}
- return result;
}
[HttpPost("/article")]
- public async Task CreateArticle(long id, string title, string description, string author, string date, int lectureTime)
+ public async Task CreateArticle(Article article)
{
- return await _articleService.CreateArticle(id, title, description, author, date, lectureTime);
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(CreateArticle), article);
+ try
+ {
+ var result = (await _dataManager.ArticleService.CreateArticle(article)).ToDTO();
+ if (result == null)
+ {
+ return BadRequest($"Article not created");
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
}
[HttpDelete("/article/{id}")]
- public async Task DeleteArticle(long id)
+ public async Task DeleteArticle(long id)
{
- return await _articleService.DeleteArticle(id);
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(DeleteArticle), id);
+ try
+ {
+ var result = await _dataManager.ArticleService.DeleteArticle(id);
+ if (result == null)
+ {
+ return NotFound($"Article ID {id} not found");
+ }
+ return Ok(result.ToDTO());
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
}
[HttpPut("/article/{id}")]
- public async Task UpdateArticle(long id, Article? a)
+ public async Task UpdateArticle(long id, Article? a)
{
- return await _articleService.UpdateArticle(id, a);
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(UpdateArticle), id, a);
+ try
+ {
+ var result = (await _dataManager.ArticleService.UpdateArticle(id, a)).ToDTO();
+ if (result == null)
+ {
+ return NotFound($"Article ID {id} not found");
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
}
diff --git a/Verax_API_EF/Verax_API_EF/API/Controllers/FormulaireController.cs b/Verax_API_EF/Verax_API_EF/API/Controllers/FormulaireController.cs
index db249bd..fcf25aa 100644
--- a/Verax_API_EF/Verax_API_EF/API/Controllers/FormulaireController.cs
+++ b/Verax_API_EF/Verax_API_EF/API/Controllers/FormulaireController.cs
@@ -4,6 +4,7 @@ using Model;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
+using API_Mapping;
namespace API.Controllers
{
@@ -11,41 +12,118 @@ namespace API.Controllers
[ApiController]
public class FormulaireController : ControllerBase
{
- private readonly IFormulaireService _form;
+ //private readonly IFormulaireService _form;
+ private readonly IDataManager _dataManager;
+ private readonly ILogger _logger;
- public FormulaireController(IFormulaireService iform)
+ public FormulaireController(IDataManager dataManager, ILogger logger)
{
- this._form = iform;
+ this._dataManager = dataManager;
+ this._logger = logger;
}
- [HttpGet("/forms/{id}")]
- public Task> GetAllForm()
+ [HttpGet("/formulaires")]
+ public async Task GetAllForm([FromQuery] int index = 0, [FromQuery] int count = 10, [FromQuery] FormOrderCriteria orderCriteria = FormOrderCriteria.None)
{
- throw new NotImplementedException();
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(GetAllForm), index, count, orderCriteria);
+ try
+ {
+ var result = (await _dataManager.FormulaireService.GetAllForm(index, count, orderCriteria)).Select(f => f.ToDTO());
+ if (result == null)
+ {
+ return NotFound($"No form found");
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
+
}
- [HttpGet("{id}")]
- public Task GetById(long id)
+ [HttpGet("/formulaire/{id}")]
+ public async Task GetById(long id)
{
- throw new NotImplementedException();
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(GetById), id);
+ try
+ {
+ var result = (await _dataManager.FormulaireService.GetById(id)).ToDTO();
+ if (result == null)
+ {
+ return NotFound($"form ID {id} not found");
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
+
+
}
- [HttpPost]
- public Task CreateForm(Formulaire formulaire)
+ [HttpPost ("/formulaire")]
+ public async Task CreateForm(Formulaire formulaire)
{
- throw new NotImplementedException();
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(CreateForm), formulaire);
+ try
+ {
+ var result = (await _dataManager.FormulaireService.CreateForm(formulaire)).ToDTO();
+ if (result == null)
+ {
+ return BadRequest($"Form Id {formulaire.Id} already exists");
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
}
- [HttpDelete("{id}")]
- public Task DeleteForm(long id)
+ [HttpDelete("/formulaire/{id}")]
+ public async Task DeleteForm(long id)
{
- throw new NotImplementedException();
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(DeleteForm), id);
+ try
+ {
+ var result = (await _dataManager.FormulaireService.DeleteForm(id)).ToDTO();
+ if (result == null)
+ {
+ return NotFound($"Form Id {id} not found");
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
}
- [HttpPut("{id}")]
- public Task UpdateForm(long id, Formulaire formulaire)
+ [HttpPut("/formulaire/{id}")]
+ public async Task UpdateForm(long id, Formulaire formulaire)
{
- throw new NotImplementedException();
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(UpdateForm), formulaire);
+
+ try
+ {
+ var result = (await _dataManager.FormulaireService.UpdateForm(id, formulaire)).ToDTO();
+ if (result == null)
+ {
+ return NotFound($"form Id {id} not found");
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
}
}
}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/API/Controllers/UserController.cs b/Verax_API_EF/Verax_API_EF/API/Controllers/UserController.cs
index 6a90231..5ca51f4 100644
--- a/Verax_API_EF/Verax_API_EF/API/Controllers/UserController.cs
+++ b/Verax_API_EF/Verax_API_EF/API/Controllers/UserController.cs
@@ -2,6 +2,8 @@
using Microsoft.AspNetCore.Mvc;
using API_Services;
using Model;
+using API_Mapping;
+using Entities;
namespace API.Controllers
@@ -10,42 +12,220 @@ namespace API.Controllers
[ApiController]
public class UserController : ControllerBase
{
- private readonly IUserService _us;
-
- public UserController(IUserService us)
+ //private readonly IUserService _us;
+ private readonly IDataManager _dataManager;
+ private readonly ILogger _logger;
+ public UserController(IDataManager dataManager, ILogger logger)
+ {
+ this._logger = logger;
+ this._dataManager = dataManager;
+ }
+
+ [HttpGet("/users")]
+ public async Task GetAll([FromQuery] int index = 0, [FromQuery] int count = 10, [FromQuery] UserOrderCriteria orderCriteria = UserOrderCriteria.None)
{
- this._us = us;
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(GetAll), index, count, orderCriteria);
+ try
+ {
+ var result = (await _dataManager.UserService.GetAll(index, count, orderCriteria)).Select(u => u.ToDTO());
+ if (result == null)
+ {
+ return NotFound($"No user found with the given parameters");
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
+ }
+
+ [HttpGet("/user/{pseudo}")]
+ public async Task GetByPseudo(string pseudo)
+ {
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(GetByPseudo), pseudo);
+ try
+ {
+ var result = (await _dataManager.UserService.GetByPseudo(pseudo)).ToDTO();
+ if (result == null)
+ {
+ return NotFound($"Psuedo {pseudo} not found");
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
+
}
[HttpPost("/user")]
- public Task Create(User user)
+ public async Task Create(User user)
{
- throw new NotImplementedException();
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(Create), user);
+ try
+ {
+ var result = (await _dataManager.UserService.Create(user)).ToDTO();
+ if (result == null)
+ {
+ return BadRequest($"User {user.Pseudo} already exists");
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
+
}
[HttpPut("/user/{pseudo}")]
- public Task Update(User user)
+ public async Task Update(User user, string pseudo)
{
- throw new NotImplementedException();
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(Update), user, pseudo);
+ try
+ {
+ var result = (await _dataManager.UserService.Update(user, pseudo)).ToDTO();
+ if (result == null)
+ {
+ return NotFound();
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
+
}
[HttpDelete("/user/{pseudo}")]
- public Task Delete(string pseudo)
+ public async Task Delete(string pseudo)
{
- throw new NotImplementedException();
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(Delete), pseudo);
+ try
+ {
+ var result = (await _dataManager.UserService.Delete(pseudo)).ToDTO();
+ if (result == null)
+ {
+ return NotFound();
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
}
-
- [HttpGet("/user/{pseudo}")]
- public Task GetByPseudo(string pseudo)
+
+ [HttpGet("/articleUsers")]
+ public async Task GetAllArticleUsers()
+ {
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(GetAllArticleUsers), "");
+ try
{
- throw new NotImplementedException();
+ var result = (await _dataManager.UserService.GetAllArticleUsers()).Select(u => u.ToDTO());
+ if (result == null)
+ {
+ return NoContent();
+ }
+ return Ok(result);
}
-
- [HttpGet("/users")]
- public Task> GetAll()
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
+ }
+
+ [HttpGet("/user/{pseudo}/article")]
+ public async Task GetArticleUser(string pseudo)
+ {
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(GetArticleUser), pseudo);
+ try
{
- throw new NotImplementedException();
+ var result = (await _dataManager.UserService.GetArticleUser(pseudo)).Select(a => a.ToDTO());
+ if (result == null)
+ {
+ return NoContent();
+ }
+ return Ok(result);
}
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
+ }
+
+ [HttpPost("/user/article")]
+ public async Task CreateArticleUser(ArticleUserEntity articleUser)
+ {
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(CreateArticleUser), articleUser);
+ try
+ {
+ Console.WriteLine(articleUser);
+ var result = await _dataManager.UserService.CreateArticleUser(articleUser);
+ if (result == null)
+ {
+ return BadRequest($"ArticleUser {articleUser.UserEntityPseudo} already exists");
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
+ }
+
+ [HttpDelete("/user/{pseudo}/{id}")]
+ public async Task DeleteArticleUser(string pseudo, long id)
+ {
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(DeleteArticleUser), pseudo);
+ try
+ {
+ var result = await _dataManager.UserService.DeleteArticleUser(pseudo, id);
+ if (!result)
+ {
+ return BadRequest($"User {pseudo} or {id} does not exist");
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
+ }
+
+ [HttpPut("/user/{pseudo}/article")]
+ public async Task UpdateArticleUser(ArticleUserEntity articleUser)
+ {
+ _logger.LogInformation("Executing {Action} - with parameters: {Parameters}",nameof(UpdateArticleUser), articleUser);
+ try
+ {
+ var result = (await _dataManager.UserService.UpdateArticleUser(articleUser));
+ if (!result)
+ {
+ return BadRequest($"ArticleUser {articleUser.UserEntityPseudo} does not exist");
+ }
+ return Ok(result);
+ }
+ catch (Exception error)
+ {
+ _logger.LogError(error.Message);
+ return BadRequest(error.Message);
+ }
+ }
+
+
}
}
diff --git a/Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db b/Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db
index 9a47220..175a9e3 100644
Binary files a/Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db and b/Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db differ
diff --git a/Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db-shm b/Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db-shm
index 5e1d073..d5fc9fb 100644
Binary files a/Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db-shm and b/Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db-shm differ
diff --git a/Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db-wal b/Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db-wal
index 497cd7d..7605da6 100644
Binary files a/Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db-wal and b/Verax_API_EF/Verax_API_EF/API/Entity_FrameWork.Article.db-wal differ
diff --git a/Verax_API_EF/Verax_API_EF/API/Program.cs b/Verax_API_EF/Verax_API_EF/API/Program.cs
index 9bf4f16..06fffd8 100644
--- a/Verax_API_EF/Verax_API_EF/API/Program.cs
+++ b/Verax_API_EF/Verax_API_EF/API/Program.cs
@@ -2,6 +2,7 @@ using API_Services;
using DbContextLib;
using DbDataManager;
using Microsoft.EntityFrameworkCore;
+using Model;
using StubbedContextLib;
var builder = WebApplication.CreateBuilder(args);
@@ -20,9 +21,9 @@ builder.Services.AddDbContext(options =>
options.UseSqlite("Data Source=Entity_FrameWork.Article.db");
});
-builder.Services.AddScoped();
-builder.Services.AddScoped();
-builder.Services.AddScoped();
+builder.Services.AddScoped();
+
+
var app = builder.Build();
@@ -38,7 +39,7 @@ app.MapControllers();
using var scoped = app.Services.CreateScope();
var libraryContext = scoped.ServiceProvider.GetService();
-//libraryContext.Database.EnsureCreated();
+//libraryContext.Database.EnsureCreated();
libraryContext.Database.Migrate();
app.Run();
diff --git a/Verax_API_EF/Verax_API_EF/API/log.txt b/Verax_API_EF/Verax_API_EF/API/log.txt
new file mode 100644
index 0000000..7d66f59
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/API/log.txt
@@ -0,0 +1,34 @@
+info: 03/15/2024 16:59:22.173 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
+ Executed DbCommand (6ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
+ SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
+info: 03/15/2024 16:59:22.176 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
+ Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
+ SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
+info: 03/15/2024 16:59:22.182 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
+ Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
+ SELECT "MigrationId", "ProductVersion"
+ FROM "__EFMigrationsHistory"
+ ORDER BY "MigrationId";
+info: 03/15/2024 16:59:22.190 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
+ No migrations were applied. The database is already up to date.
+info: 03/15/2024 16:59:30.063 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
+ Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
+ SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title"
+ FROM "ArticleSet" AS "a"
+info: 03/15/2024 17:08:29.557 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
+ Executed DbCommand (6ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
+ SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
+info: 03/15/2024 17:08:29.561 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
+ Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
+ SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
+info: 03/15/2024 17:08:29.567 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
+ Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
+ SELECT "MigrationId", "ProductVersion"
+ FROM "__EFMigrationsHistory"
+ ORDER BY "MigrationId";
+info: 03/15/2024 17:08:29.575 RelationalEventId.MigrationsNotApplied[20405] (Microsoft.EntityFrameworkCore.Migrations)
+ No migrations were applied. The database is already up to date.
+info: 03/15/2024 17:08:33.305 RelationalEventId.CommandExecuted[20101] (Microsoft.EntityFrameworkCore.Database.Command)
+ Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
+ SELECT "a"."Id", "a"."Author", "a"."DatePublished", "a"."Description", "a"."LectureTime", "a"."Title"
+ FROM "ArticleSet" AS "a"
diff --git a/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManager.cs b/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManager.cs
index 6e4990b..d147171 100644
--- a/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManager.cs
+++ b/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManager.cs
@@ -1,12 +1,30 @@
+using API_Services;
using DbContextLib;
+using Model;
namespace DbDataManager;
-public class DbManager
+public class DbManager : IDataManager
{
- protected LibraryContext _context;
+ protected LibraryContext _context { get; set; }
+
public DbManager()
{
_context = new LibraryContext();
+ ArticleService = new DbManagerArticle(_context);
+ UserService = new DbManagerUser(_context);
+ FormulaireService = new DbManagerFormulaire(_context);
}
+
+ public DbManager(LibraryContext context)
+ {
+ _context = context;
+ ArticleService = new DbManagerArticle(_context);
+ UserService = new DbManagerUser(_context);
+ FormulaireService = new DbManagerFormulaire(_context);
+ }
+
+ public IArticleService ArticleService { get; set; }
+ public IUserService UserService { get; set; }
+ public IFormulaireService FormulaireService { get; set; }
}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerArticle.cs b/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerArticle.cs
index adf65c2..9daf046 100644
--- a/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerArticle.cs
+++ b/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerArticle.cs
@@ -11,25 +11,60 @@ public class DbManagerArticle : IArticleService
private readonly LibraryContext _context;
public DbManagerArticle(LibraryContext context)
+ => this._context = context;
+ public async Task> GetAllArticles(int index, int count, ArticleOrderCriteria orderCriterium)
{
- _context = context;
+ List articles = new List();
+
+ switch (orderCriterium)
+ {
+ case ArticleOrderCriteria.None:
+ articles = _context.ArticleSet.Select(a => a.ToModel()).ToList();
+ break;
+ case ArticleOrderCriteria.ByLectureTime:
+ articles = _context.ArticleSet.OrderBy(a => a.LectureTime).Select(a => a.ToModel()).ToList();
+ break;
+ case ArticleOrderCriteria.ByTitle:
+ articles = _context.ArticleSet.OrderBy(a => a.Title).Select(a => a.ToModel()).ToList();
+ break;
+ case ArticleOrderCriteria.ByAuthor:
+ articles = _context.ArticleSet.OrderBy(a => a.Author).Select(a => a.ToModel()).ToList();
+ break;
+ case ArticleOrderCriteria.ByDatePublished:
+ articles = _context.ArticleSet.OrderBy(a => a.DatePublished).Select(a => a.ToModel()).ToList();
+ break;
+ case ArticleOrderCriteria.ByDescription:
+ articles = _context.ArticleSet.OrderBy(a => a.Description).Select(a => a.ToModel()).ToList();
+ break;
+ default:
+ articles = _context.ArticleSet.Select(a => a.ToModel()).ToList();
+ break;
+ }
+ return await Task.FromResult(articles.AsEnumerable());
}
+ public Task GetArticleById(int id)
+ {
+ var entity = _context.ArticleSet.FirstOrDefault(a => a.Id == id);
+ if (entity == null) return Task.FromResult(null);
+ return Task.FromResult(entity.ToModel());
+ }
- public async Task CreateArticle(long id, string title, string description, string author, string date, int lectureTime)
+
+ public async Task CreateArticle(Article article)
{
var entity = new Entities.ArticleEntity()
{
- Id = id,
- Title = title,
- Description = description,
- Author = author,
- DatePublished = date,
- LectureTime = lectureTime,
+ Id = article.Id,
+ Title = article.Title,
+ Description = article.Description,
+ Author = article.Author,
+ DatePublished = article.DatePublished,
+ LectureTime = article.LectureTime,
};
_context.ArticleSet.Add(entity);
- await _context.SaveChangesAsync();
-
+ var result = await _context.SaveChangesAsync();
+ if (result == 0) return await Task.FromResult(null);
return entity.ToModel();
}
@@ -39,31 +74,25 @@ public class DbManagerArticle : IArticleService
Console.WriteLine(entity);
if (entity == null) return null;
_context.ArticleSet.Remove(entity);
- await _context.SaveChangesAsync();
+ var result = await _context.SaveChangesAsync();
+ if (result == 0) return await Task.FromResult(null);
return entity.ToModel();
}
- public async Task UpdateArticle(long id, Article? a)
+ public async Task UpdateArticle(long id, Article? a)
{
var entity = _context.ArticleSet.FirstOrDefault(a => a.Id == id);
- if (entity == null) return false;
+ if (entity == null) return await Task.FromResult(null);
entity.Title = a.Title;
entity.Description = a.Description;
entity.Author = a.Author;
entity.DatePublished = a.DatePublished;
entity.LectureTime = a.LectureTime;
- await _context.SaveChangesAsync();
- return true;
- }
-
- public Task GetArticleById(int id)
- {
- var entity = _context.ArticleSet.FirstOrDefault(a => a.Id == id);
- return Task.FromResult(entity.ToModel());
- }
-
- public async Task> GetAllArticles()
- {
- return await Task.FromResult(_context.ArticleSet.Select(a => a.ToModel()).AsEnumerable());
+ var result = await _context.SaveChangesAsync();
+ if (result == 0) return await Task.FromResult(null);
+ return entity.ToModel();
}
+
+
+
}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerFormulaire.cs b/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerFormulaire.cs
index b459078..914a606 100644
--- a/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerFormulaire.cs
+++ b/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerFormulaire.cs
@@ -11,13 +11,33 @@ public class DbManagerFormulaire : IFormulaireService
private readonly LibraryContext _context;
public DbManagerFormulaire(LibraryContext context)
- {
- _context = context;
- }
+ => this._context = context;
- public async Task> GetAllForm()
+ public async Task> GetAllForm(int index, int count, FormOrderCriteria orderCriteria)
{
- return await Task.FromResult(_context.FormSet.Select(f => f.ToModel()).AsEnumerable());
+ List formulaireList = new List();
+ switch (orderCriteria)
+ {
+ case FormOrderCriteria.None:
+ formulaireList = _context.FormSet.Skip(index * count).Select(f => f.ToModel()).ToList();
+ break;
+ case FormOrderCriteria.ByTheme:
+ formulaireList = _context.FormSet.Skip(index * count).OrderBy(f => f.Theme).Select(f => f.ToModel()).ToList();
+ break;
+ case FormOrderCriteria.ByLien:
+ formulaireList = _context.FormSet.Skip(index * count).OrderBy(f => f.Link).Select(f => f.ToModel()).ToList();
+ break;
+ case FormOrderCriteria.ByDate:
+ formulaireList = _context.FormSet.Skip(index * count).OrderBy(f => f.DatePublication).Select(f => f.ToModel()).ToList();
+ break;
+ case FormOrderCriteria.ByPseudo:
+ formulaireList = _context.FormSet.Skip(index * count).OrderBy(f => f.UserEntityPseudo).Select(f => f.ToModel()).ToList();
+ break;
+ default:
+ formulaireList = _context.FormSet.Skip(index * count).Select(f => f.ToModel()).ToList();
+ break;
+ }
+ return await Task.FromResult(formulaireList.AsEnumerable());
}
public async Task GetById(long id)
@@ -32,33 +52,38 @@ public class DbManagerFormulaire : IFormulaireService
var entity = new FormEntity()
{
Id = formulaire.Id,
- Pseudo = formulaire.Pseudo,
+ Link = formulaire.Lien,
Theme = formulaire.Theme,
- DatePublication = formulaire.Date
+ DatePublication = formulaire.Date,
+ UserEntityPseudo = formulaire.UserPseudo
};
_context.FormSet.Add(entity);
- await _context.SaveChangesAsync();
+ var result = await _context.SaveChangesAsync();
+ if (result == 0) return await Task.FromResult(null);
return entity.ToModel();
}
- public async Task DeleteForm(long id)
+ public async Task DeleteForm(long id)
{
var entity = _context.FormSet.FirstOrDefault(f => f.Id == id);
- if (entity == null) return false;
+ if (entity == null) return Task.FromResult(null).Result;
_context.FormSet.Remove(entity);
- await _context.SaveChangesAsync();
- return true;
+ var result = await _context.SaveChangesAsync();
+ if (result == 0) return await Task.FromResult(null);
+ return entity.ToModel();
}
- public async Task UpdateForm(long id, Formulaire formulaire)
+ public async Task UpdateForm(long id, Formulaire formulaire)
{
var entity = _context.FormSet.FirstOrDefault(f => f.Id == id);
- if (entity == null) return false;
- entity.Pseudo = formulaire.Pseudo;
+ if (entity == null) return Task.FromResult(null).Result;
entity.Theme = formulaire.Theme;
entity.DatePublication = formulaire.Date;
- await _context.SaveChangesAsync();
- return true;
+ entity.Link = formulaire.Lien;
+ entity.UserEntityPseudo = formulaire.UserPseudo;
+ var result = await _context.SaveChangesAsync();
+ if (result == 0) return await Task.FromResult(null);
+ return entity.ToModel();
}
}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerUser.cs b/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerUser.cs
index e7ce2c4..5c196d7 100644
--- a/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerUser.cs
+++ b/Verax_API_EF/Verax_API_EF/API_DbDataManager/DbManagerUser.cs
@@ -11,11 +11,39 @@ public class DbManagerUser: IUserService
private readonly LibraryContext _context;
public DbManagerUser(LibraryContext context)
+ => this._context = context;
+
+ public async Task> GetAll(int index, int count, UserOrderCriteria orderCriteria)
{
- _context = context;
+ List users = new List();
+ switch(orderCriteria)
+ {
+ case UserOrderCriteria.None:
+ users = _context.UserSet.Skip(index * count).Select(u => u.ToModel()).ToList();
+ break;
+ case UserOrderCriteria.ByFirstName:
+ users = _context.UserSet.Skip(index * count).OrderBy(u => u.Prenom).Select(u => u.ToModel()).ToList();
+ break;
+ case UserOrderCriteria.ByLastName:
+ users = _context.UserSet.Skip(index * count).OrderBy(u => u.Nom).Select(u => u.ToModel()).ToList();
+ break;
+ default:
+ users = _context.UserSet.Skip(index * count).Select(u => u.ToModel()).ToList();
+ break;
+
+ }
+ return await Task.FromResult(users.AsEnumerable());
+
}
- public async Task Create(User user)
+ public async Task GetByPseudo(string pseudo)
+ {
+ var entity = _context.UserSet.FirstOrDefault(u => u.Pseudo == pseudo);
+ if (entity == null) return await Task.FromResult(null);
+ return await Task.FromResult(entity.ToModel());
+ }
+
+ public async Task Create(User user)
{
var entity = new UserEntity()
{
@@ -27,41 +55,99 @@ public class DbManagerUser: IUserService
Role = user.Role
};
_context.UserSet.Add(entity);
- await _context.SaveChangesAsync();
- return true;
+ var result = await _context.SaveChangesAsync();
+ if (result == 0) return await Task.FromResult(null);
+ return await Task.FromResult(entity.ToModel());
}
- public async Task Update(User user)
+ public async Task Update(User user, string pseudo)
{
- var entity = _context.UserSet.FirstOrDefault(u => u.Pseudo == user.Pseudo);
- if (entity == null) return false;
+ var entity = _context.UserSet.FirstOrDefault(u => u.Pseudo == pseudo);
+ if (entity == null) return await Task.FromResult(null);
entity.Mdp = user.Mdp;
entity.Mail = user.Mail;
entity.Role = user.Role;
entity.Prenom = user.Prenom;
entity.Nom = user.Nom;
- await _context.SaveChangesAsync();
- return true;
+ var result = await _context.SaveChangesAsync();
+ if (result == 0) return await Task.FromResult(null);
+ return await Task.FromResult(entity.ToModel());
}
- public async Task Delete(string pseudo)
+ public async Task Delete(string pseudo)
{
var entity = _context.UserSet.FirstOrDefault(u => u.Pseudo == pseudo);
- if (entity == null) return await Task.FromResult(false);
+ if (entity == null) return await Task.FromResult(null);
_context.UserSet.Remove(entity);
+ var result = await _context.SaveChangesAsync();
+ if (result == 0) return await Task.FromResult(null);
+ return await Task.FromResult(entity.ToModel());
+ }
+
+ public async Task> GetAllArticleUsers()
+ {
+ var entities = _context.ArticleUserSet.ToList();
+ List users = new List();
+ foreach( var articleUser in entities)
+ {
+ var user = _context.UserSet.FirstOrDefault(u => u.Pseudo.Equals(articleUser.UserEntityPseudo));
+ if (user != null) users.Add(user);
+ }
+ if (users == null) return await Task.FromResult>(null);
+ return await Task.FromResult(users.Select(u => u.ToModel()).AsEnumerable());
+ }
+
+
+ public async Task> GetArticleUser(string pseudo)
+ {
+ var entities = _context.ArticleUserSet.Where(a => a.UserEntityPseudo.Equals(pseudo));
+ List articles = new List();
+ foreach (var article in entities)
+ {
+ var art = _context.ArticleSet.FirstOrDefault(a => a.Id.Equals(article.ArticleEntityId));
+ if (art != null) articles.Add(art);
+ }
+ if (articles == null) return await Task.FromResult>(null);
+ return await Task.FromResult(articles.Select(a => a.ToModel()).AsEnumerable());
+ }
+
+
+ public async Task CreateArticleUser(ArticleUserEntity articleUser)
+ {
+ var result = await GetByPseudo(articleUser.UserEntityPseudo);
+ if (result == null) return await Task.FromResult(false);
+ var entity = new ArticleUserEntity()
+ {
+ ArticleEntityId = articleUser.ArticleEntityId,
+ UserEntityPseudo = articleUser.UserEntityPseudo
+ };
+ if (entity == null) return await Task.FromResult(false);
+ _context.ArticleUserSet.Add(entity);
await _context.SaveChangesAsync();
return await Task.FromResult(true);
-
}
-
- public async Task GetByPseudo(string pseudo)
+
+ public async Task DeleteArticleUser(string pseudo, long id)
{
- var entity = _context.UserSet.FirstOrDefault(u => u.Pseudo == pseudo);
- return await Task.FromResult(entity.ToModel());
+
+ var entity = _context.ArticleUserSet.FirstOrDefault(a => a.UserEntityPseudo.Equals(pseudo) && a.ArticleEntityId.Equals(id));
+ if (entity == null) return await Task.FromResult(false);
+ _context.ArticleUserSet.Remove(entity);
+ await _context.SaveChangesAsync();
+ return await Task.FromResult(true);
}
-
- public async Task> GetAll()
+
+ public async Task UpdateArticleUser(ArticleUserEntity articleUser)
{
- return await Task.FromResult(_context.UserSet.Select(u => u.ToModel()).AsEnumerable());
+ var entity = _context.ArticleUserSet.FirstOrDefault(a => a.UserEntityPseudo.Equals(articleUser.UserEntityPseudo));
+ if (entity == null) return await Task.FromResult(false);
+ entity.ArticleEntityId = articleUser.ArticleEntityId;
+ entity.UserEntityPseudo = articleUser.UserEntityPseudo;
+ await _context.SaveChangesAsync();
+ return await Task.FromResult(true);
}
+
+
+
+
}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/API_DbDataManager/Extensions.cs b/Verax_API_EF/Verax_API_EF/API_DbDataManager/Extensions.cs
index 511f7da..d35d9b8 100644
--- a/Verax_API_EF/Verax_API_EF/API_DbDataManager/Extensions.cs
+++ b/Verax_API_EF/Verax_API_EF/API_DbDataManager/Extensions.cs
@@ -26,10 +26,10 @@ public static class Extensions
=> new User{ Pseudo = user.Pseudo, Mdp = user.Mdp, Prenom = user.Prenom, Nom = user.Nom, Mail = user.Mail, Role = user.Role};
public static FormEntity ToEntity(this Formulaire form)
- => new FormEntity{ Id = form.Id, Pseudo = form.Pseudo, Theme = form.Theme, Link = form.Lien};
+ => new FormEntity{ Id = form.Id, UserEntityPseudo = form.UserPseudo, Theme = form.Theme, Link = form.Lien};
public static Formulaire ToModel(this FormEntity form)
- => new Formulaire{ Id = form.Id, Pseudo = form.Pseudo, Theme = form.Theme, Lien = form.Link};
+ => new Formulaire{ Id = form.Id, UserPseudo = form.UserEntityPseudo, Theme = form.Theme, Lien = form.Link};
}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/API_Mapping/ArticleMapper.cs b/Verax_API_EF/Verax_API_EF/API_Mapping/ArticleMapper.cs
index 9767dd8..3c9e57f 100644
--- a/Verax_API_EF/Verax_API_EF/API_Mapping/ArticleMapper.cs
+++ b/Verax_API_EF/Verax_API_EF/API_Mapping/ArticleMapper.cs
@@ -5,7 +5,7 @@ namespace API_Mapping;
public static class ArticleMapper
{
- public static ArticleDTO ToDTO(this Article a) => new()
+ public static ArticleDTO ToDTO(this Article? a) => new()
{
Id = a.Id,
Title = a.Title,
diff --git a/Verax_API_EF/Verax_API_EF/API_Mapping/FormulaireMapping.cs b/Verax_API_EF/Verax_API_EF/API_Mapping/FormulaireMapping.cs
index eef95ef..7a779ab 100644
--- a/Verax_API_EF/Verax_API_EF/API_Mapping/FormulaireMapping.cs
+++ b/Verax_API_EF/Verax_API_EF/API_Mapping/FormulaireMapping.cs
@@ -5,13 +5,13 @@ namespace API_Mapping;
public static class FormulaireMapping
{
- public static FormulaireDTO ToDTO(this Formulaire f) => new()
+ public static FormulaireDTO ToDTO(this Formulaire? f) => new()
{
Id = f.Id,
Theme = f.Theme,
Date = f.Date,
Lien = f.Lien,
- Pseudo = f.Pseudo
+ UserPseudo = f.UserPseudo
};
public static Formulaire ToModel(this FormulaireDTO f) => new()
@@ -20,6 +20,6 @@ public static class FormulaireMapping
Theme = f.Theme,
Date = f.Date,
Lien = f.Lien,
- Pseudo = f.Pseudo
+ UserPseudo = f.UserPseudo
};
}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/API_Mapping/UserMapping.cs b/Verax_API_EF/Verax_API_EF/API_Mapping/UserMapping.cs
index ef5cd9c..53789e6 100644
--- a/Verax_API_EF/Verax_API_EF/API_Mapping/UserMapping.cs
+++ b/Verax_API_EF/Verax_API_EF/API_Mapping/UserMapping.cs
@@ -5,7 +5,7 @@ namespace API_Mapping;
public static class UserMapping
{
- public static UserDTO ToDTO(this User u) => new()
+ public static UserDTO ToDTO(this User? u) => new()
{
Pseudo = u.Pseudo,
Mdp = u.Mdp,
diff --git a/Verax_API_EF/Verax_API_EF/API_Model/FormulaireDTO.cs b/Verax_API_EF/Verax_API_EF/API_Model/FormulaireDTO.cs
index df256d4..67b5e38 100644
--- a/Verax_API_EF/Verax_API_EF/API_Model/FormulaireDTO.cs
+++ b/Verax_API_EF/Verax_API_EF/API_Model/FormulaireDTO.cs
@@ -6,7 +6,7 @@ public class FormulaireDTO
public string Theme { get; set; }
public string Date { get; set; }
public string Lien { get; set; }
- public string Pseudo { get; set; }
+ public string UserPseudo { get; set; }
}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/API_Services/API_Services.csproj b/Verax_API_EF/Verax_API_EF/API_Services/API_Services.csproj
index b0ff0a6..4fe8b1d 100644
--- a/Verax_API_EF/Verax_API_EF/API_Services/API_Services.csproj
+++ b/Verax_API_EF/Verax_API_EF/API_Services/API_Services.csproj
@@ -7,6 +7,7 @@
+
diff --git a/Verax_API_EF/Verax_API_EF/API_Services/IArticleService.cs b/Verax_API_EF/Verax_API_EF/API_Services/IArticleService.cs
index 2bbeac2..967eddf 100644
--- a/Verax_API_EF/Verax_API_EF/API_Services/IArticleService.cs
+++ b/Verax_API_EF/Verax_API_EF/API_Services/IArticleService.cs
@@ -4,16 +4,18 @@ namespace API_Services
{
public interface IArticleService
{
- Task CreateArticle(long id, string title, string description, string author, string date,
- int lectureTime);
+
+ Task> GetAllArticles(int index, int count, ArticleOrderCriteria orderCriterium);
+
+ Task GetArticleById(int id);
- Task DeleteArticle(long id);
- Task UpdateArticle(long id, Article? a);
+ Task CreateArticle(Article article);
- Task GetArticleById(int id);
+ Task DeleteArticle(long id);
- Task> GetAllArticles();
-
+ Task UpdateArticle(long id, Article? a);
+
+
}
}
diff --git a/Verax_API_EF/Verax_API_EF/API_Services/IDataManager.cs b/Verax_API_EF/Verax_API_EF/API_Services/IDataManager.cs
new file mode 100644
index 0000000..d5abbc8
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/API_Services/IDataManager.cs
@@ -0,0 +1,13 @@
+namespace Model;
+using API_Services;
+
+public interface IDataManager
+{
+
+
+ IArticleService ArticleService { get; }
+ IUserService UserService { get; }
+ IFormulaireService FormulaireService { get; }
+
+}
+
diff --git a/Verax_API_EF/Verax_API_EF/API_Services/IFormulaireService.cs b/Verax_API_EF/Verax_API_EF/API_Services/IFormulaireService.cs
index e3159c0..0b0d444 100644
--- a/Verax_API_EF/Verax_API_EF/API_Services/IFormulaireService.cs
+++ b/Verax_API_EF/Verax_API_EF/API_Services/IFormulaireService.cs
@@ -5,14 +5,14 @@ namespace API_Services;
public interface IFormulaireService
{
- Task> GetAllForm();
+ Task> GetAllForm(int index, int count, FormOrderCriteria orderCriteria);
Task GetById(long id);
Task CreateForm(Formulaire formulaire);
- Task DeleteForm(long id);
+ Task DeleteForm(long id);
- Task UpdateForm(long id, Formulaire formulaire);
+ Task UpdateForm(long id, Formulaire formulaire);
}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/API_Services/IUserService.cs b/Verax_API_EF/Verax_API_EF/API_Services/IUserService.cs
index 480cb43..ed48afb 100644
--- a/Verax_API_EF/Verax_API_EF/API_Services/IUserService.cs
+++ b/Verax_API_EF/Verax_API_EF/API_Services/IUserService.cs
@@ -1,18 +1,29 @@
-using Model;
+using Entities;
+using Model;
namespace API_Services
{
public interface IUserService
{
- Task Create(User user);
- Task Update(User user);
-
- Task Delete(string pseudo);
-
-
+
+ Task> GetAll(int index, int count, UserOrderCriteria orderCriteria);
Task GetByPseudo(string pseudo);
+ Task Create(User user);
+ Task Update(User user, string pseudo);
+
+ Task Delete(string pseudo);
+
+ Task> GetAllArticleUsers();
+ Task> GetArticleUser(string pseudo);
+
+ Task CreateArticleUser(ArticleUserEntity articleUser);
+
+ Task DeleteArticleUser(string pseudo, long id);
+
+ Task UpdateArticleUser(ArticleUserEntity articleUser);
+
+
- Task> GetAll();
diff --git a/Verax_API_EF/Verax_API_EF/API_Tests_Console/API_Tests_Console.csproj b/Verax_API_EF/Verax_API_EF/API_Tests_Console/API_Tests_Console.csproj
new file mode 100644
index 0000000..1faee3d
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/API_Tests_Console/API_Tests_Console.csproj
@@ -0,0 +1,15 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/Verax_API_EF/Verax_API_EF/API_Tests_Console/Tests_Console.cs b/Verax_API_EF/Verax_API_EF/API_Tests_Console/Tests_Console.cs
new file mode 100644
index 0000000..aff59a0
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/API_Tests_Console/Tests_Console.cs
@@ -0,0 +1,427 @@
+// See https://aka.ms/new-console-template for more information
+
+using System.Text;
+using System.Text.Json;
+using Entities;
+using Model;
+
+class Tests_Console
+{
+ static readonly HttpClient client = new HttpClient();
+
+
+ static async Task Main(string[] args)
+ {
+ //await TestUser();
+ await TestFormulaire();
+ //await TestArticle();
+ }
+
+ private static async Task TestFormulaire()
+ {
+ await TestFormulaireGetAll();
+ //await TestFormulaireGetId();
+ //await TestFormulaireCreate();
+ //await TestFormulaireDelete();
+ //await TestFormulaireUpdate();
+ }
+
+ private static async Task TestUser()
+ {
+ //await TestUserGetAll();
+ //await TestUserGetId();
+ //await TestUserCreate();
+ //await TestUserDelete();
+ //await TestUserUpdate();
+ //await TestGetAllArticleUser();
+ //await TestGetArticleByUser();
+ //await TestCreateArticleUser();
+ //await TestDeleteArticleUser();
+ //await TestUpdateArticleUser();
+ }
+
+
+ static async Task TestArticle()
+ {
+ await TestArticleGetId();
+ await TestArticleCreate();
+ await TestArticleGetAll();
+ await TestArticleDelete();
+ await TestArticleUpdate();
+ }
+
+ static async Task TestArticleGetAll()
+ {
+ try
+ {
+ var response = await client.GetAsync("http://localhost:5052/api/Article");
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestArticleGetId()
+ {
+ try
+ {
+ var response = await client.GetAsync("http://localhost:5052/article/1");
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestArticleCreate()
+ {
+ try
+ {
+ var article = new Article()
+ {
+ Title = "Test",
+ Description = "Test",
+ Author = "Test",
+ DatePublished = "Test",
+ LectureTime = 0
+ };
+ var json = JsonSerializer.Serialize(article);
+ var data = new StringContent(json, Encoding.UTF8, "application/json");
+ var response = await client.PostAsync("http://localhost:5052/article", data);
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestArticleDelete()
+ {
+ try
+ {
+ var response = await client.DeleteAsync("http://localhost:5052/article/4");
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestArticleUpdate()
+ {
+ try
+ {
+ var article = new Article()
+ {
+ Title = "Louis",
+ Description = "Je",
+ Author = "T'",
+ DatePublished = "aime",
+ LectureTime = 0
+ };
+ var json = JsonSerializer.Serialize(article);
+ var data = new StringContent(json, Encoding.UTF8, "application/json");
+ var response = await client.PutAsync("http://localhost:5052/article/1", data);
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestFormulaireGetAll()
+ {
+ try
+ {
+ var response = await client.GetAsync("http://localhost:5052/formulaires");
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestFormulaireGetId()
+ {
+ try
+ {
+ var response = await client.GetAsync("http://localhost:5052/formulaire/2");
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestFormulaireCreate()
+ {
+ try
+ {
+ var formulaire = new Formulaire()
+ {
+ Theme = "Test",
+ Date = "Test",
+ Lien = "Test",
+ UserPseudo = "Sha"
+ };
+ var json = JsonSerializer.Serialize(formulaire);
+ var data = new StringContent(json, Encoding.UTF8, "application/json");
+ var response = await client.PostAsync("http://localhost:5052/formulaire", data);
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestFormulaireDelete()
+ {
+ try
+ {
+ var response = await client.DeleteAsync("http://localhost:5052/formulaire/5");
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestFormulaireUpdate()
+ {
+ try
+ {
+ var formulaire = new Formulaire()
+ {
+ Theme = "J'",
+ Date = "aime",
+ Lien = "Les",
+ UserPseudo = "Sha"
+ };
+ var json = JsonSerializer.Serialize(formulaire);
+ var data = new StringContent(json, Encoding.UTF8, "application/json");
+ var response = await client.PutAsync("http://localhost:5052/formulaire/4", data);
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestUserGetAll()
+ {
+ try
+ {
+ var response = await client.GetAsync("http://localhost:5052/users");
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestUserGetId()
+ {
+ try
+ {
+ var response = await client.GetAsync("http://localhost:5052/user/Sha");
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestUserCreate()
+ {
+ try
+ {
+ var user = new User()
+ {
+ Pseudo = "J",
+ Nom = "'",
+ Prenom = "aime",
+ Mail = "les",
+ Mdp = "pieds",
+ Role = "Admin"
+ };
+ var json = JsonSerializer.Serialize(user);
+ var data = new StringContent(json, Encoding.UTF8, "application/json");
+ var response = await client.PostAsync("http://localhost:5052/user", data);
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestUserDelete()
+ {
+ try
+ {
+ var response = await client.DeleteAsync("http://localhost:5052/user/J");
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestUserUpdate()
+ {
+ try
+ {
+ var user = new User()
+ {
+ Pseudo = "Sha",
+ Nom = "J'",
+ Prenom = "aime",
+ Mail = "les",
+ Mdp = "pieds",
+ Role = "Admin"
+ };
+ var json = JsonSerializer.Serialize(user);
+ var data = new StringContent(json, Encoding.UTF8, "application/json");
+ var response = await client.PutAsync("http://localhost:5052/user/Sha", data);
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestGetAllArticleUser()
+ {
+ try
+ {
+ var response = await client.GetAsync("http://localhost:5052/ArticleUsers");
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestGetArticleByUser()
+ {
+ try
+ {
+ var response = await client.GetAsync("http://localhost:5052/user/Sha/article");
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestCreateArticleUser()
+ {
+ try
+ {
+ var articleUser = new ArticleUserEntity()
+ {
+ ArticleEntityId = 1,
+ UserEntityPseudo = "Sha"
+ };
+ var json = JsonSerializer.Serialize(articleUser);
+ var data = new StringContent(json, Encoding.UTF8, "application/json");
+ var response = await client.PostAsync("http://localhost:5052/user/article", data);
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestDeleteArticleUser()
+ {
+ try
+ {
+ var response = await client.DeleteAsync("http://localhost:5052/user/Sha/article");
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+ static async Task TestUpdateArticleUser()
+ {
+ try
+ {
+ var articleUser = new ArticleUserEntity()
+ {
+ ArticleEntityId = 1,
+ UserEntityPseudo = "Sha"
+ };
+ var json = JsonSerializer.Serialize(articleUser);
+ var data = new StringContent(json, Encoding.UTF8, "application/json");
+ var response = await client.PutAsync("http://localhost:5052/user/Sha/article", data);
+ response.EnsureSuccessStatusCode();
+ var responseBody = await response.Content.ReadAsStringAsync();
+ Console.WriteLine(responseBody);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/API_Unit_Test/API_Unit_Test.csproj b/Verax_API_EF/Verax_API_EF/API_Unit_Test/API_Unit_Test.csproj
new file mode 100644
index 0000000..bf9fa2b
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/API_Unit_Test/API_Unit_Test.csproj
@@ -0,0 +1,30 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+ false
+ true
+
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
diff --git a/Verax_API_EF/Verax_API_EF/API_Unit_Test/GlobalUsings.cs b/Verax_API_EF/Verax_API_EF/API_Unit_Test/GlobalUsings.cs
new file mode 100644
index 0000000..8c927eb
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/API_Unit_Test/GlobalUsings.cs
@@ -0,0 +1 @@
+global using Xunit;
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/API_Unit_Test/UnitTest_Article.cs b/Verax_API_EF/Verax_API_EF/API_Unit_Test/UnitTest_Article.cs
new file mode 100644
index 0000000..0219dbd
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/API_Unit_Test/UnitTest_Article.cs
@@ -0,0 +1,129 @@
+using API_Services;
+using Model;
+using Moq;
+
+namespace API_Unit_Test;
+
+public class UnitTest_Article
+{
+
+
+
+
+
+ [Fact]
+ public void TestGetArticleById()
+ {
+ var mockArticleService = new Mock();
+ var expected = new Article()
+ {
+ Id = 1,
+ Title = "Test",
+ Description = "Test",
+ Author = "Test",
+ DatePublished = "Test",
+ LectureTime = 10
+ };
+ mockArticleService.Setup(x => x.GetArticleById(1)).ReturnsAsync(expected);
+ var result = mockArticleService.Object.GetArticleById(1);
+ Assert.Equal(expected, result.Result);
+ }
+
+ [Fact]
+ public void TestGetAllArticles()
+ {
+ var mockArticleService = new Mock();
+ var expected = new List()
+ {
+ new Article()
+ {
+ Id = 1,
+ Title = "Test",
+ Description = "Test",
+ Author = "Test",
+ DatePublished = "Test",
+ LectureTime = 10
+ },
+ new Article()
+ {
+ Id = 2,
+ Title = "Test",
+ Description = "Test",
+ Author = "Test",
+ DatePublished = "Test",
+ LectureTime = 10
+ }
+ };
+ mockArticleService.Setup(x => x.GetAllArticles(0, 10, ArticleOrderCriteria.None)).ReturnsAsync(expected);
+ var result = mockArticleService.Object.GetAllArticles(0, 10, ArticleOrderCriteria.None);
+ Assert.Equal(expected, result.Result);
+ }
+
+ [Fact]
+ public void TestAddArticle()
+ {
+ var mockArticleService = new Mock();
+ var expected = new Article()
+ {
+ Id = 1,
+ Title = "Test",
+ Description = "Test",
+ Author = "Test",
+ DatePublished = "Test",
+ LectureTime = 10
+ };
+ mockArticleService.Setup(x => x.CreateArticle(expected)).ReturnsAsync(expected);
+ var result = mockArticleService.Object.CreateArticle(expected);
+ Assert.Equal(expected, result.Result);
+ }
+
+ [Fact]
+ public void UpdateArticle()
+ {
+ var mockArticleService = new Mock();
+ var expected = new Article()
+ {
+ Title = "Test",
+ Description = "Test",
+ Author = "Test",
+ DatePublished = "Test",
+ LectureTime = 10
+ };
+ mockArticleService.Setup(x => x.CreateArticle(expected));
+ var result = mockArticleService.Object.CreateArticle(expected);
+ Assert.Equal(1, result.Id );
+ var updated = new Article()
+ {
+ Title = "Updated Test",
+ Description = "Test",
+ Author = "Test",
+ DatePublished = "Test",
+ LectureTime = 10
+ };
+ mockArticleService.Setup(x => x.UpdateArticle(1, updated)).ReturnsAsync(updated);
+ var resultUpdated = mockArticleService.Object.UpdateArticle(1, updated);
+ Assert.Equal(updated ,resultUpdated.Result);
+ }
+
+ [Fact]
+ static void DeletedArticle()
+ {
+ var mockArticleService = new Mock();
+ var expected = new Article()
+ {
+ Id = 1,
+ Title = "Test",
+ Description = "Test",
+ Author = "Test",
+ DatePublished = "Test",
+ LectureTime = 10
+ };
+ mockArticleService.Setup(x => x.CreateArticle(expected)).ReturnsAsync(expected);
+ var result = mockArticleService.Object.CreateArticle(expected);
+ Assert.Equal(expected, result.Result);
+ mockArticleService.Setup(x => x.DeleteArticle(1)).ReturnsAsync(expected);
+ var resultDeleted = mockArticleService.Object.DeleteArticle(1);
+ Assert.Equal(expected, result.Result);
+ }
+
+}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/API_Unit_Test/UnitTest_Form.cs b/Verax_API_EF/Verax_API_EF/API_Unit_Test/UnitTest_Form.cs
new file mode 100644
index 0000000..bc9b615
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/API_Unit_Test/UnitTest_Form.cs
@@ -0,0 +1,99 @@
+using API_Services;
+using Model;
+using Moq;
+
+namespace API_Unit_Test;
+
+public class UnitTest_Form
+{
+ [Fact]
+ public void TestGetAllForm()
+ {
+ var mockFormService = new Mock();
+ var expected = new List()
+ {
+ new Formulaire()
+ {
+ Lien = "Test",
+ Theme = "Test",
+ Date = "Test",
+ UserPseudo = "Test"
+ },
+ new Formulaire()
+ {
+ Lien = "Test",
+ Theme = "Test",
+ Date = "Test",
+ UserPseudo = "Test"
+ }
+ };
+ mockFormService.Setup(x => x.GetAllForm(0, 10, FormOrderCriteria.None)).ReturnsAsync(expected);
+ var result = mockFormService.Object.GetAllForm(0, 10, FormOrderCriteria.None);
+ Assert.Equal(expected, result.Result);
+ }
+
+ [Fact]
+ public void TestGetFormById()
+ {
+ var mockFormService = new Mock();
+ var expected = new Formulaire()
+ {
+ Lien = "Test",
+ Theme = "Test",
+ Date = "Test",
+ UserPseudo = "Test"
+ };
+ mockFormService.Setup(x => x.GetById(1)).ReturnsAsync(expected);
+ var result = mockFormService.Object.GetById(1);
+ Assert.Equal(expected, result.Result);
+ }
+
+ [Fact]
+ public void TestCreateForm()
+ {
+ var mockFormService = new Mock();
+ var expected = new Formulaire()
+ {
+ Lien = "Test",
+ Theme = "Test",
+ Date = "Test",
+ UserPseudo = "Test"
+ };
+ mockFormService.Setup(x => x.CreateForm(expected)).ReturnsAsync(expected);
+ var result = mockFormService.Object.CreateForm(expected);
+ Assert.Equal(expected, result.Result);
+ }
+
+ [Fact]
+ public void TestUpdateForm()
+ {
+ var mockFormService = new Mock();
+ var expected = new Formulaire()
+ {
+ Lien = "Test",
+ Theme = "Test",
+ Date = "Test",
+ UserPseudo = "Test"
+ };
+ mockFormService.Setup(x => x.CreateForm(expected)).ReturnsAsync(expected);
+ var result = mockFormService.Object.CreateForm(expected);
+ Assert.Equal(expected, result.Result);
+ }
+
+ [Fact]
+ public void TestDeleteForm()
+ {
+ var mockFormService = new Mock();
+ var expected = new Formulaire()
+ {
+ Lien = "Test",
+ Theme = "Test",
+ Date = "Test",
+ UserPseudo = "Test"
+ };
+ mockFormService.Setup(x => x.DeleteForm(1)).ReturnsAsync(expected);
+ var result = mockFormService.Object.DeleteForm(1);
+ Assert.Equal(expected, result.Result);
+ }
+
+}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/API_Unit_Test/UnitTest_User.cs b/Verax_API_EF/Verax_API_EF/API_Unit_Test/UnitTest_User.cs
new file mode 100644
index 0000000..9634bcd
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/API_Unit_Test/UnitTest_User.cs
@@ -0,0 +1,215 @@
+using API_Services;
+using Entities;
+using Model;
+using Moq;
+
+namespace API_Unit_Test;
+
+public class UnitTest_User
+{
+
+ [Fact]
+ static void TestAllUser()
+ {
+ var mockUserService = new Mock();
+ var expected = new List()
+ {
+ new User()
+ {
+ Pseudo = "Tofgasy",
+ Prenom = "Tony",
+ Nom = "Fages",
+ Mail = "mail@mail.com",
+ Mdp = "1234",
+ Role = "Admin"
+ },
+ new User()
+ {
+ Pseudo = "Blizzard",
+ Prenom = "Louis",
+ Nom = "Laborie",
+ Mail = "mail@mail.com",
+ Mdp = "1234",
+ Role = "Admin",
+ },
+ };
+ mockUserService.Setup(x => x.GetAll(0, 10, UserOrderCriteria.None)).ReturnsAsync(expected);
+ var result = mockUserService.Object.GetAll(0, 10, UserOrderCriteria.None);
+ Assert.Equal(expected, result.Result);
+
+ }
+
+ [Fact]
+ static void TestGetUserByPseudo()
+ {
+ var mockUserService = new Mock();
+ var expected = new User()
+ {
+ Pseudo = "Tofgasy",
+ Prenom = "Tony",
+ Nom = "Fages",
+ Mail = "mail@mail.com",
+ Mdp = "1234",
+ Role = "Admin"
+ };
+ mockUserService.Setup(x => x.GetByPseudo("Tofgasy")).ReturnsAsync(expected);
+ var result = mockUserService.Object.GetByPseudo("Tofgasy");
+ Assert.Equal(expected, result.Result);
+ }
+
+ [Fact]
+ static void TestCreateUser()
+ {
+ var mockUserService = new Mock();
+ var user = new User()
+ {
+ Pseudo = "Tofgasy",
+ Prenom = "Tony",
+ Nom = "Fages",
+ Mail = "mail@mail.com",
+ Mdp = "1234",
+ Role = "Admin"
+ };
+ mockUserService.Setup(x => x.Create(user)).ReturnsAsync(user);
+ var result = mockUserService.Object.Create(user);
+ Assert.Equal( user,result.Result);
+ }
+
+ [Fact]
+ static void TestUpdateUser()
+ {
+ var mockUserService = new Mock();
+ var user = new User()
+ {
+ Pseudo = "Tofgasy",
+ Prenom = "Tonio",
+ Nom = "Fages",
+ Mail = "mail@mail.com",
+ Mdp = "1234",
+ Role = "Admin"
+ };
+ mockUserService.Setup(x => x.Update(user, "Tofgasy")).ReturnsAsync(user);
+ var result = mockUserService.Object.Update(user, "Tofgasy");
+ Assert.Equal( user,result.Result);
+ }
+
+ [Fact]
+ static void TestDeleteUser()
+ {
+ var mockUserService = new Mock();
+ var user = new User()
+ {
+ Pseudo = "Tofgasy",
+ Prenom = "Tonio",
+ Nom = "Fages",
+ Mail = "mail@mail.com",
+ Mdp = "1234",
+ Role = "Admin"
+ };
+ mockUserService.Setup(x => x.Delete("Tofgasy")).ReturnsAsync(user);
+ var result = mockUserService.Object.Delete("Tofgasy");
+ Assert.Equal( user,result.Result);
+ }
+
+
+ [Fact]
+ static void TestGetAllArticleUsers()
+ {
+ var mockUserService = new Mock();
+ var expected = new List()
+ {
+ new User()
+ {
+ Pseudo = "Tofgasy",
+ Prenom = "Tony",
+ Nom = "Fages",
+ Mail = "",
+ Mdp = "",
+ Role = "",
+ },
+ new User()
+ {
+ Pseudo = "Blizzard",
+ Prenom = "Louis",
+ Nom = "Laborie",
+ Mail = "",
+ Mdp = "",
+ Role = "",
+ },
+ };
+ mockUserService.Setup(x => x.GetAllArticleUsers()).ReturnsAsync(expected);
+ var result = mockUserService.Object.GetAllArticleUsers();
+ Assert.Equal(expected, result.Result);
+ }
+
+ [Fact]
+ static void TestGetArticleUser()
+ {
+ var mockUserService = new Mock();
+ var expected = new List()
+ {
+ new Article()
+ {
+ Id = 1,
+ Title = "Test",
+ Description = "Test",
+ Author = "Test",
+ DatePublished = "Test",
+ LectureTime = 10
+ },
+ new Article()
+ {
+ Id = 2,
+ Title = "Test",
+ Description = "Test",
+ Author = "Test",
+ DatePublished = "Test",
+ LectureTime = 10
+ }
+ };
+ mockUserService.Setup(x => x.GetArticleUser("Tofgasy")).ReturnsAsync(expected);
+ var result = mockUserService.Object.GetArticleUser("Tofgasy");
+ Assert.Equal(expected, result.Result);
+ }
+
+ [Fact]
+ static void TestCreateArticleUser()
+ {
+ var mockUserService = new Mock();
+ var articleUser = new ArticleUserEntity()
+ {
+ ArticleEntityId = 1,
+ UserEntityPseudo = "Tofgasy"
+ };
+ mockUserService.Setup(x => x.CreateArticleUser(articleUser)).ReturnsAsync(true);
+ var result = mockUserService.Object.CreateArticleUser(articleUser);
+ Assert.True(result.Result);
+ }
+
+ [Fact]
+ static void TestDeleteArticleUser()
+ {
+ var mockUserService = new Mock();
+ mockUserService.Setup(x => x.DeleteArticleUser("Tofgasy", 1)).ReturnsAsync(true);
+ var result = mockUserService.Object.DeleteArticleUser("Tofgasy", 1);
+ Assert.True(result.Result);
+ }
+
+ [Fact]
+ static void TestUpdateArticleUser()
+ {
+ var mockUserService = new Mock();
+ var articleUser = new ArticleUserEntity()
+ {
+ ArticleEntityId = 1,
+ UserEntityPseudo = "Tofgasy"
+ };
+ mockUserService.Setup(x => x.UpdateArticleUser(articleUser)).ReturnsAsync(true);
+ var result = mockUserService.Object.UpdateArticleUser(articleUser);
+ Assert.True(result.Result);
+ }
+
+
+
+}
+
diff --git a/Verax_API_EF/Verax_API_EF/DbContextLib/LibraryContext.cs b/Verax_API_EF/Verax_API_EF/DbContextLib/LibraryContext.cs
index 58c2539..c62563b 100644
--- a/Verax_API_EF/Verax_API_EF/DbContextLib/LibraryContext.cs
+++ b/Verax_API_EF/Verax_API_EF/DbContextLib/LibraryContext.cs
@@ -1,26 +1,37 @@
using Entities;
using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Logging;
namespace DbContextLib;
public class LibraryContext : DbContext
{
+
public LibraryContext()
: base()
- { }
+ {
+ }
public LibraryContext(DbContextOptions options)
: base(options)
- { }
-
-
-
+ {
+ }
+
+
+
public DbSet ArticleSet { get; set; }
public DbSet UserSet { get; set; }
public DbSet FormSet { get; set; }
-
+
+ public DbSet ArticleUserSet { get; set; }
+
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
+ optionsBuilder.LogTo(message =>
+ {
+ using var logFile = new StreamWriter("log.txt", append: true);
+ logFile.WriteLine(message);
+ }, LogLevel.Information);
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlite($"Data Source=Entity_FrameWork.Article.db");
@@ -35,17 +46,17 @@ public class LibraryContext : DbContext
.HasMany(a => a.Users)
.WithMany(a => a.Articles)
.UsingEntity();
-
+
modelBuilder.Entity()
.HasMany(u => u.Forms)
.WithOne(f => f.User)
- .HasForeignKey(f => f.UserEntityId);
-
+ .HasForeignKey(f => f.UserEntityPseudo);
+
modelBuilder.Entity()
.HasOne(f => f.User)
.WithMany(u => u.Forms)
- .HasForeignKey(f => f.UserEntityId);
-
+ .HasForeignKey(f => f.UserEntityPseudo);
+ /*
modelBuilder.Entity().HasData(
new ArticleEntity
{
@@ -74,79 +85,85 @@ public class LibraryContext : DbContext
Description = "M&M's new recipe is out and it's the best chocolate ever",
DatePublished = "2022-02-06",
LectureTime = 1,
- Author = "M&M's Red"
+ Author = "M&M's Red"
}
);
modelBuilder.Entity().HasData(
new UserEntity
{
- Id = 1, Nom = "Fages", Prenom = "Tony", Pseudo = "TonyF", Mail = "tony@gmail.com", Mdp = "1234", Role = "Admin"
+ Nom = "Fages", Prenom = "Tony", Pseudo = "TonyF", Mail = "tony@gmail.com", Mdp = "1234", Role = "Admin"
},
new UserEntity
{
- Id = 2, Nom = "Smith", Prenom = "Tom", Pseudo = "TomS", Mail = "tom@mail.com", Mdp = "1234",
+ Nom = "Smith", Prenom = "Tom", Pseudo = "TomS", Mail = "tom@mail.com", Mdp = "1234",
Role = "User"
},
new UserEntity
{
- Id = 3, Nom = "M&M's", Prenom = "Red", Pseudo = "RedM", Mail = "M&M#mail.com", Mdp = "1234", Role = "Modérator"
+ Nom = "M&M's", Prenom = "Red", Pseudo = "RedM", Mail = "M&M#mail.com", Mdp = "1234", Role = "Modérator"
+ },
+ new UserEntity
+ {
+ Nom = "Cascarra", Prenom = "Cascarra", Pseudo = "Sha", Mail = "ShaCasca@gmail.com", Mdp = "1234", Role = "Admin"
+ },
+ new UserEntity
+ {
+ Nom = "Sillard", Prenom = "Noa", Pseudo = "NoaSil", Mail = "", Mdp = "1234", Role = "Admin"
}
);
-
+
modelBuilder.Entity().HasData(
new ArticleUserEntity
{
ArticleEntityId = 1,
- UserEntityId = 1
+ UserEntityPseudo = "TonyF"
},
new ArticleUserEntity
{
ArticleEntityId = 2,
- UserEntityId = 2
+ UserEntityPseudo = "NoaSil"
},
new ArticleUserEntity
{
ArticleEntityId = 3,
- UserEntityId = 3
+ UserEntityPseudo = "Sha"
},
new ArticleUserEntity
{
ArticleEntityId = 3,
- UserEntityId = 1
+ UserEntityPseudo = "RedM"
},
new ArticleUserEntity
{
ArticleEntityId = 2,
- UserEntityId = 3
+ UserEntityPseudo = "TomS"
}
);
-
+
modelBuilder.Entity().HasData(
new FormEntity
{
- Id = 1,
- Pseudo= "Form 1",
+ Id = 1,
DatePublication = "Form 1 Description",
Link = "hhtp://form1.com",
- UserEntityId = 1
+ UserEntityPseudo = "Sha"
},
new FormEntity
{
Id = 2,
- Pseudo= "Form 2",
DatePublication = "Form 2 Description",
Link = "hhtp://form2.com",
- UserEntityId = 2
+ UserEntityPseudo = "Sha"
},
new FormEntity
{
Id = 3,
- Pseudo= "Form 3",
DatePublication = "Form 3 Description",
Link = "hhtp://form3.com",
- UserEntityId = 3
+ UserEntityPseudo = "Sha"
}
);
+ */
}
}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/StubbedContextLib/Migrations/20240307182411_mrg1.Designer.cs b/Verax_API_EF/Verax_API_EF/DbContextLib/Migrations/20240312155559_mrg1.Designer.cs
similarity index 74%
rename from Verax_API_EF/Verax_API_EF/StubbedContextLib/Migrations/20240307182411_mrg1.Designer.cs
rename to Verax_API_EF/Verax_API_EF/DbContextLib/Migrations/20240312155559_mrg1.Designer.cs
index 1340e2b..850cf0c 100644
--- a/Verax_API_EF/Verax_API_EF/StubbedContextLib/Migrations/20240307182411_mrg1.Designer.cs
+++ b/Verax_API_EF/Verax_API_EF/DbContextLib/Migrations/20240312155559_mrg1.Designer.cs
@@ -1,16 +1,16 @@
//
+using DbContextLib;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using StubbedContextLib;
#nullable disable
-namespace StubbedContextLib.Migrations
+namespace DbContextLib.Migrations
{
- [DbContext(typeof(StubbedContext))]
- [Migration("20240307182411_mrg1")]
+ [DbContext(typeof(LibraryContext))]
+ [Migration("20240312155559_mrg1")]
partial class mrg1
{
///
@@ -83,40 +83,40 @@ namespace StubbedContextLib.Migrations
b.Property("ArticleEntityId")
.HasColumnType("INTEGER");
- b.Property("UserEntityId")
- .HasColumnType("INTEGER");
+ b.Property("UserEntityPseudo")
+ .HasColumnType("TEXT");
- b.HasKey("ArticleEntityId", "UserEntityId");
+ b.HasKey("ArticleEntityId", "UserEntityPseudo");
- b.HasIndex("UserEntityId");
+ b.HasIndex("UserEntityPseudo");
- b.ToTable("ArticleUserEntity");
+ b.ToTable("ArticleUserSet");
b.HasData(
new
{
ArticleEntityId = 1L,
- UserEntityId = 1L
+ UserEntityPseudo = "TonyF"
},
new
{
ArticleEntityId = 2L,
- UserEntityId = 2L
+ UserEntityPseudo = "NoaSil"
},
new
{
ArticleEntityId = 3L,
- UserEntityId = 3L
+ UserEntityPseudo = "Sha"
},
new
{
ArticleEntityId = 3L,
- UserEntityId = 1L
+ UserEntityPseudo = "RedM"
},
new
{
ArticleEntityId = 2L,
- UserEntityId = 3L
+ UserEntityPseudo = "TomS"
});
});
@@ -134,29 +134,51 @@ namespace StubbedContextLib.Migrations
.IsRequired()
.HasColumnType("TEXT");
- b.Property("Pseudo")
+ b.Property("Theme")
.IsRequired()
.HasColumnType("TEXT");
- b.Property("Theme")
+ b.Property("UserEntityPseudo")
.IsRequired()
.HasColumnType("TEXT");
- b.Property("UserEntityId")
- .HasColumnType("INTEGER");
-
b.HasKey("Id");
- b.HasIndex("UserEntityId");
+ b.HasIndex("UserEntityPseudo");
b.ToTable("FormSet");
+
+ b.HasData(
+ new
+ {
+ Id = 1L,
+ DatePublication = "Form 1 Description",
+ Link = "hhtp://form1.com",
+ Theme = "",
+ UserEntityPseudo = "Sha"
+ },
+ new
+ {
+ Id = 2L,
+ DatePublication = "Form 2 Description",
+ Link = "hhtp://form2.com",
+ Theme = "",
+ UserEntityPseudo = "Sha"
+ },
+ new
+ {
+ Id = 3L,
+ DatePublication = "Form 3 Description",
+ Link = "hhtp://form3.com",
+ Theme = "",
+ UserEntityPseudo = "Sha"
+ });
});
modelBuilder.Entity("Entities.UserEntity", b =>
{
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
+ b.Property("Pseudo")
+ .HasColumnType("TEXT");
b.Property("Mail")
.IsRequired()
@@ -174,48 +196,59 @@ namespace StubbedContextLib.Migrations
.IsRequired()
.HasColumnType("TEXT");
- b.Property("Pseudo")
- .IsRequired()
- .HasColumnType("TEXT");
-
b.Property("Role")
.IsRequired()
.HasColumnType("TEXT");
- b.HasKey("Id");
+ b.HasKey("Pseudo");
b.ToTable("UserSet");
b.HasData(
new
{
- Id = 1L,
+ Pseudo = "TonyF",
Mail = "tony@gmail.com",
Mdp = "1234",
Nom = "Fages",
Prenom = "Tony",
- Pseudo = "TonyF",
Role = "Admin"
},
new
{
- Id = 2L,
+ Pseudo = "TomS",
Mail = "tom@mail.com",
Mdp = "1234",
Nom = "Smith",
Prenom = "Tom",
- Pseudo = "TomS",
Role = "User"
},
new
{
- Id = 3L,
+ Pseudo = "RedM",
Mail = "M&M#mail.com",
Mdp = "1234",
Nom = "M&M's",
Prenom = "Red",
- Pseudo = "RedM",
Role = "Modérator"
+ },
+ new
+ {
+ Pseudo = "Sha",
+ Mail = "ShaCasca@gmail.com",
+ Mdp = "1234",
+ Nom = "Cascarra",
+ Prenom = "Cascarra",
+ Role = "Admin"
+ },
+ new
+ {
+ Pseudo = "NoaSil",
+ Mail = "",
+ Mdp = "1234",
+ Nom = "Sillard",
+ Prenom = "Noa",
+ Role = "Admin"
});
});
@@ -229,7 +262,7 @@ namespace StubbedContextLib.Migrations
b.HasOne("Entities.UserEntity", null)
.WithMany()
- .HasForeignKey("UserEntityId")
+ .HasForeignKey("UserEntityPseudo")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
@@ -238,7 +271,7 @@ namespace StubbedContextLib.Migrations
{
b.HasOne("Entities.UserEntity", "User")
.WithMany("Forms")
- .HasForeignKey("UserEntityId")
+ .HasForeignKey("UserEntityPseudo")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
diff --git a/Verax_API_EF/Verax_API_EF/StubbedContextLib/Migrations/20240307182411_mrg1.cs b/Verax_API_EF/Verax_API_EF/DbContextLib/Migrations/20240312155559_mrg1.cs
similarity index 66%
rename from Verax_API_EF/Verax_API_EF/StubbedContextLib/Migrations/20240307182411_mrg1.cs
rename to Verax_API_EF/Verax_API_EF/DbContextLib/Migrations/20240312155559_mrg1.cs
index a40c540..df6fd44 100644
--- a/Verax_API_EF/Verax_API_EF/StubbedContextLib/Migrations/20240307182411_mrg1.cs
+++ b/Verax_API_EF/Verax_API_EF/DbContextLib/Migrations/20240312155559_mrg1.cs
@@ -4,7 +4,7 @@
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
-namespace StubbedContextLib.Migrations
+namespace DbContextLib.Migrations
{
///
public partial class mrg1 : Migration
@@ -33,8 +33,6 @@ namespace StubbedContextLib.Migrations
name: "UserSet",
columns: table => new
{
- Id = table.Column(type: "INTEGER", nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
Pseudo = table.Column(type: "TEXT", nullable: false),
Mdp = table.Column(type: "TEXT", nullable: false),
Nom = table.Column(type: "TEXT", nullable: false),
@@ -44,30 +42,30 @@ namespace StubbedContextLib.Migrations
},
constraints: table =>
{
- table.PrimaryKey("PK_UserSet", x => x.Id);
+ table.PrimaryKey("PK_UserSet", x => x.Pseudo);
});
migrationBuilder.CreateTable(
- name: "ArticleUserEntity",
+ name: "ArticleUserSet",
columns: table => new
{
- UserEntityId = table.Column(type: "INTEGER", nullable: false),
+ UserEntityPseudo = table.Column(type: "TEXT", nullable: false),
ArticleEntityId = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
- table.PrimaryKey("PK_ArticleUserEntity", x => new { x.ArticleEntityId, x.UserEntityId });
+ table.PrimaryKey("PK_ArticleUserSet", x => new { x.ArticleEntityId, x.UserEntityPseudo });
table.ForeignKey(
- name: "FK_ArticleUserEntity_ArticleSet_ArticleEntityId",
+ name: "FK_ArticleUserSet_ArticleSet_ArticleEntityId",
column: x => x.ArticleEntityId,
principalTable: "ArticleSet",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
- name: "FK_ArticleUserEntity_UserSet_UserEntityId",
- column: x => x.UserEntityId,
+ name: "FK_ArticleUserSet_UserSet_UserEntityPseudo",
+ column: x => x.UserEntityPseudo,
principalTable: "UserSet",
- principalColumn: "Id",
+ principalColumn: "Pseudo",
onDelete: ReferentialAction.Cascade);
});
@@ -80,17 +78,16 @@ namespace StubbedContextLib.Migrations
Theme = table.Column(type: "TEXT", nullable: false),
DatePublication = table.Column(type: "TEXT", nullable: false),
Link = table.Column(type: "TEXT", nullable: false),
- Pseudo = table.Column(type: "TEXT", nullable: false),
- UserEntityId = table.Column(type: "INTEGER", nullable: false)
+ UserEntityPseudo = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_FormSet", x => x.Id);
table.ForeignKey(
- name: "FK_FormSet_UserSet_UserEntityId",
- column: x => x.UserEntityId,
+ name: "FK_FormSet_UserSet_UserEntityPseudo",
+ column: x => x.UserEntityPseudo,
principalTable: "UserSet",
- principalColumn: "Id",
+ principalColumn: "Pseudo",
onDelete: ReferentialAction.Cascade);
});
@@ -106,42 +103,54 @@ namespace StubbedContextLib.Migrations
migrationBuilder.InsertData(
table: "UserSet",
- columns: new[] { "Id", "Mail", "Mdp", "Nom", "Prenom", "Pseudo", "Role" },
+ columns: new[] { "Pseudo", "Mail", "Mdp", "Nom", "Prenom", "Role" },
values: new object[,]
{
- { 1L, "tony@gmail.com", "1234", "Fages", "Tony", "TonyF", "Admin" },
- { 2L, "tom@mail.com", "1234", "Smith", "Tom", "TomS", "User" },
- { 3L, "M&M#mail.com", "1234", "M&M's", "Red", "RedM", "Modérator" }
+ { "NoaSil", "", "1234", "Sillard", "Noa", "Admin" },
+ { "RedM", "M&M#mail.com", "1234", "M&M's", "Red", "Modérator" },
+ { "Sha", "ShaCasca@gmail.com", "1234", "Cascarra", "Cascarra", "Admin" },
+ { "TomS", "tom@mail.com", "1234", "Smith", "Tom", "User" },
+ { "TonyF", "tony@gmail.com", "1234", "Fages", "Tony", "Admin" }
});
migrationBuilder.InsertData(
- table: "ArticleUserEntity",
- columns: new[] { "ArticleEntityId", "UserEntityId" },
+ table: "ArticleUserSet",
+ columns: new[] { "ArticleEntityId", "UserEntityPseudo" },
+ values: new object[,]
+ {
+ { 1L, "TonyF" },
+ { 2L, "NoaSil" },
+ { 2L, "TomS" },
+ { 3L, "RedM" },
+ { 3L, "Sha" }
+ });
+
+ migrationBuilder.InsertData(
+ table: "FormSet",
+ columns: new[] { "Id", "DatePublication", "Link", "Theme", "UserEntityPseudo" },
values: new object[,]
{
- { 1L, 1L },
- { 2L, 2L },
- { 2L, 3L },
- { 3L, 1L },
- { 3L, 3L }
+ { 1L, "Form 1 Description", "hhtp://form1.com", "", "Sha" },
+ { 2L, "Form 2 Description", "hhtp://form2.com", "", "Sha" },
+ { 3L, "Form 3 Description", "hhtp://form3.com", "", "Sha" }
});
migrationBuilder.CreateIndex(
- name: "IX_ArticleUserEntity_UserEntityId",
- table: "ArticleUserEntity",
- column: "UserEntityId");
+ name: "IX_ArticleUserSet_UserEntityPseudo",
+ table: "ArticleUserSet",
+ column: "UserEntityPseudo");
migrationBuilder.CreateIndex(
- name: "IX_FormSet_UserEntityId",
+ name: "IX_FormSet_UserEntityPseudo",
table: "FormSet",
- column: "UserEntityId");
+ column: "UserEntityPseudo");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
- name: "ArticleUserEntity");
+ name: "ArticleUserSet");
migrationBuilder.DropTable(
name: "FormSet");
diff --git a/Verax_API_EF/Verax_API_EF/StubbedContextLib/Migrations/StubbedContextModelSnapshot.cs b/Verax_API_EF/Verax_API_EF/DbContextLib/Migrations/LibraryContextModelSnapshot.cs
similarity index 74%
rename from Verax_API_EF/Verax_API_EF/StubbedContextLib/Migrations/StubbedContextModelSnapshot.cs
rename to Verax_API_EF/Verax_API_EF/DbContextLib/Migrations/LibraryContextModelSnapshot.cs
index c4e950b..8cff281 100644
--- a/Verax_API_EF/Verax_API_EF/StubbedContextLib/Migrations/StubbedContextModelSnapshot.cs
+++ b/Verax_API_EF/Verax_API_EF/DbContextLib/Migrations/LibraryContextModelSnapshot.cs
@@ -1,15 +1,15 @@
//
+using DbContextLib;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using StubbedContextLib;
#nullable disable
-namespace StubbedContextLib.Migrations
+namespace DbContextLib.Migrations
{
- [DbContext(typeof(StubbedContext))]
- partial class StubbedContextModelSnapshot : ModelSnapshot
+ [DbContext(typeof(LibraryContext))]
+ partial class LibraryContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
@@ -80,40 +80,40 @@ namespace StubbedContextLib.Migrations
b.Property("ArticleEntityId")
.HasColumnType("INTEGER");
- b.Property("UserEntityId")
- .HasColumnType("INTEGER");
+ b.Property("UserEntityPseudo")
+ .HasColumnType("TEXT");
- b.HasKey("ArticleEntityId", "UserEntityId");
+ b.HasKey("ArticleEntityId", "UserEntityPseudo");
- b.HasIndex("UserEntityId");
+ b.HasIndex("UserEntityPseudo");
- b.ToTable("ArticleUserEntity");
+ b.ToTable("ArticleUserSet");
b.HasData(
new
{
ArticleEntityId = 1L,
- UserEntityId = 1L
+ UserEntityPseudo = "TonyF"
},
new
{
ArticleEntityId = 2L,
- UserEntityId = 2L
+ UserEntityPseudo = "NoaSil"
},
new
{
ArticleEntityId = 3L,
- UserEntityId = 3L
+ UserEntityPseudo = "Sha"
},
new
{
ArticleEntityId = 3L,
- UserEntityId = 1L
+ UserEntityPseudo = "RedM"
},
new
{
ArticleEntityId = 2L,
- UserEntityId = 3L
+ UserEntityPseudo = "TomS"
});
});
@@ -131,29 +131,51 @@ namespace StubbedContextLib.Migrations
.IsRequired()
.HasColumnType("TEXT");
- b.Property("Pseudo")
+ b.Property("Theme")
.IsRequired()
.HasColumnType("TEXT");
- b.Property("Theme")
+ b.Property("UserEntityPseudo")
.IsRequired()
.HasColumnType("TEXT");
- b.Property("UserEntityId")
- .HasColumnType("INTEGER");
-
b.HasKey("Id");
- b.HasIndex("UserEntityId");
+ b.HasIndex("UserEntityPseudo");
b.ToTable("FormSet");
+
+ b.HasData(
+ new
+ {
+ Id = 1L,
+ DatePublication = "Form 1 Description",
+ Link = "hhtp://form1.com",
+ Theme = "",
+ UserEntityPseudo = "Sha"
+ },
+ new
+ {
+ Id = 2L,
+ DatePublication = "Form 2 Description",
+ Link = "hhtp://form2.com",
+ Theme = "",
+ UserEntityPseudo = "Sha"
+ },
+ new
+ {
+ Id = 3L,
+ DatePublication = "Form 3 Description",
+ Link = "hhtp://form3.com",
+ Theme = "",
+ UserEntityPseudo = "Sha"
+ });
});
modelBuilder.Entity("Entities.UserEntity", b =>
{
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
+ b.Property("Pseudo")
+ .HasColumnType("TEXT");
b.Property("Mail")
.IsRequired()
@@ -171,48 +193,59 @@ namespace StubbedContextLib.Migrations
.IsRequired()
.HasColumnType("TEXT");
- b.Property("Pseudo")
- .IsRequired()
- .HasColumnType("TEXT");
-
b.Property("Role")
.IsRequired()
.HasColumnType("TEXT");
- b.HasKey("Id");
+ b.HasKey("Pseudo");
b.ToTable("UserSet");
b.HasData(
new
{
- Id = 1L,
+ Pseudo = "TonyF",
Mail = "tony@gmail.com",
Mdp = "1234",
Nom = "Fages",
Prenom = "Tony",
- Pseudo = "TonyF",
Role = "Admin"
},
new
{
- Id = 2L,
+ Pseudo = "TomS",
Mail = "tom@mail.com",
Mdp = "1234",
Nom = "Smith",
Prenom = "Tom",
- Pseudo = "TomS",
Role = "User"
},
new
{
- Id = 3L,
+ Pseudo = "RedM",
Mail = "M&M#mail.com",
Mdp = "1234",
Nom = "M&M's",
Prenom = "Red",
- Pseudo = "RedM",
Role = "Modérator"
+ },
+ new
+ {
+ Pseudo = "Sha",
+ Mail = "ShaCasca@gmail.com",
+ Mdp = "1234",
+ Nom = "Cascarra",
+ Prenom = "Cascarra",
+ Role = "Admin"
+ },
+ new
+ {
+ Pseudo = "NoaSil",
+ Mail = "",
+ Mdp = "1234",
+ Nom = "Sillard",
+ Prenom = "Noa",
+ Role = "Admin"
});
});
@@ -226,7 +259,7 @@ namespace StubbedContextLib.Migrations
b.HasOne("Entities.UserEntity", null)
.WithMany()
- .HasForeignKey("UserEntityId")
+ .HasForeignKey("UserEntityPseudo")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
@@ -235,7 +268,7 @@ namespace StubbedContextLib.Migrations
{
b.HasOne("Entities.UserEntity", "User")
.WithMany("Forms")
- .HasForeignKey("UserEntityId")
+ .HasForeignKey("UserEntityPseudo")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
diff --git a/Verax_API_EF/Verax_API_EF/Entities/ArticleEntity.cs b/Verax_API_EF/Verax_API_EF/Entities/ArticleEntity.cs
index f82543e..86e4c01 100644
--- a/Verax_API_EF/Verax_API_EF/Entities/ArticleEntity.cs
+++ b/Verax_API_EF/Verax_API_EF/Entities/ArticleEntity.cs
@@ -1,7 +1,10 @@
+using System.ComponentModel.DataAnnotations;
+
namespace Entities;
public class ArticleEntity
{
+ [Key]
public long Id { get; set; }
public string Title { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
diff --git a/Verax_API_EF/Verax_API_EF/Entities/ArticleUserEntity.cs b/Verax_API_EF/Verax_API_EF/Entities/ArticleUserEntity.cs
index 2faf6b7..74bb542 100644
--- a/Verax_API_EF/Verax_API_EF/Entities/ArticleUserEntity.cs
+++ b/Verax_API_EF/Verax_API_EF/Entities/ArticleUserEntity.cs
@@ -2,6 +2,6 @@ namespace Entities;
public class ArticleUserEntity
{
- public long UserEntityId { get; set; }
+ public string UserEntityPseudo { get; set; }
public long ArticleEntityId { get; set; }
}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/Entities/FormEntity.cs b/Verax_API_EF/Verax_API_EF/Entities/FormEntity.cs
index 75b43e0..6f5788a 100644
--- a/Verax_API_EF/Verax_API_EF/Entities/FormEntity.cs
+++ b/Verax_API_EF/Verax_API_EF/Entities/FormEntity.cs
@@ -1,16 +1,16 @@
+using System.ComponentModel.DataAnnotations;
+
namespace Entities;
public class FormEntity
{
+ [Key]
public long Id { get; set; }
public string Theme { get; set; } = string.Empty;
public string DatePublication { get; set; } = string.Empty;
public string Link { get; set; } = string.Empty;
- public string Pseudo { get; set; } = string.Empty;
-
- public long UserEntityId { get; set; }
- public UserEntity User { get; set; } = null;
-
+ public string UserEntityPseudo{ get; set; }
+ public UserEntity User { get; set; } = null!;
}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/Entities/UserEntity.cs b/Verax_API_EF/Verax_API_EF/Entities/UserEntity.cs
index 7d8680a..d7604c0 100644
--- a/Verax_API_EF/Verax_API_EF/Entities/UserEntity.cs
+++ b/Verax_API_EF/Verax_API_EF/Entities/UserEntity.cs
@@ -1,8 +1,10 @@
+using System.ComponentModel.DataAnnotations;
+
namespace Entities;
public class UserEntity
{
- public long Id { get; set; }
+ [Key]
public string Pseudo { get; set; } = string.Empty;
public string Mdp { get; set; } = string.Empty;
diff --git a/Verax_API_EF/Verax_API_EF/Model/Article.cs b/Verax_API_EF/Verax_API_EF/Model/Article.cs
index 497b56c..222e3a2 100644
--- a/Verax_API_EF/Verax_API_EF/Model/Article.cs
+++ b/Verax_API_EF/Verax_API_EF/Model/Article.cs
@@ -2,7 +2,7 @@ namespace Model;
public class Article
{
- public long Id { get; set; }
+ public long Id;
public string Title { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string DatePublished { get; set; } = string.Empty;
diff --git a/Verax_API_EF/Verax_API_EF/Model/ArticleOrderCriteria.cs b/Verax_API_EF/Verax_API_EF/Model/ArticleOrderCriteria.cs
new file mode 100644
index 0000000..bf34437
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/Model/ArticleOrderCriteria.cs
@@ -0,0 +1,6 @@
+namespace Model;
+
+public enum ArticleOrderCriteria
+{
+ None, ByTitle, ByAuthor, ByLectureTime, ByDatePublished, ByDescription
+}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/Model/FormOrderCriteria.cs b/Verax_API_EF/Verax_API_EF/Model/FormOrderCriteria.cs
new file mode 100644
index 0000000..f36ca89
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/Model/FormOrderCriteria.cs
@@ -0,0 +1,6 @@
+namespace Model;
+
+public enum FormOrderCriteria
+{
+ None, ByTheme, ByDate, ByPseudo, ByLien
+}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/Model/Formulaire.cs b/Verax_API_EF/Verax_API_EF/Model/Formulaire.cs
index 9b883fb..6dee834 100644
--- a/Verax_API_EF/Verax_API_EF/Model/Formulaire.cs
+++ b/Verax_API_EF/Verax_API_EF/Model/Formulaire.cs
@@ -6,5 +6,5 @@ public class Formulaire
public string Theme { get; set; }
public string Date { get; set; }
public string Lien { get; set; }
- public string Pseudo { get; set; }
+ public string UserPseudo { get; set; }
}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/Model/UserOrderCriteria.cs b/Verax_API_EF/Verax_API_EF/Model/UserOrderCriteria.cs
new file mode 100644
index 0000000..a7966db
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/Model/UserOrderCriteria.cs
@@ -0,0 +1,6 @@
+namespace Model;
+
+public enum UserOrderCriteria
+{
+ None, ByFirstName, ByLastName
+}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/StubbedContextLib/Class1.cs b/Verax_API_EF/Verax_API_EF/StubbedContextLib/Class1.cs
index b922036..6ef8d5f 100644
--- a/Verax_API_EF/Verax_API_EF/StubbedContextLib/Class1.cs
+++ b/Verax_API_EF/Verax_API_EF/StubbedContextLib/Class1.cs
@@ -45,16 +45,16 @@ public class StubbedContext : LibraryContext
modelBuilder.Entity().HasData(
new UserEntity
{
- Id = 1, Nom = "Fages", Prenom = "Tony", Pseudo = "TonyF", Mail = "tony@gmail.com", Mdp = "1234", Role = "Admin"
+ Nom = "Fages", Prenom = "Tony", Pseudo = "TonyF", Mail = "tony@gmail.com", Mdp = "1234", Role = "Admin"
},
new UserEntity
{
- Id = 2, Nom = "Smith", Prenom = "Tom", Pseudo = "TomS", Mail = "tom@mail.com", Mdp = "1234",
+ Nom = "Smith", Prenom = "Tom", Pseudo = "TomS", Mail = "tom@mail.com", Mdp = "1234",
Role = "User"
},
new UserEntity
{
- Id = 3, Nom = "M&M's", Prenom = "Red", Pseudo = "RedM", Mail = "M&M#mail.com", Mdp = "1234", Role = "Modérator"
+ Nom = "M&M's", Prenom = "Red", Pseudo = "RedM", Mail = "M&M#mail.com", Mdp = "1234", Role = "Modérator"
}
);
@@ -62,27 +62,27 @@ public class StubbedContext : LibraryContext
new ArticleUserEntity
{
ArticleEntityId = 1,
- UserEntityId = 1
+ UserEntityPseudo = "Sha"
},
new ArticleUserEntity
{
ArticleEntityId = 2,
- UserEntityId = 2
+ UserEntityPseudo = "Sha"
},
new ArticleUserEntity
{
ArticleEntityId = 3,
- UserEntityId = 3
+ UserEntityPseudo = "Sha"
},
new ArticleUserEntity
{
ArticleEntityId = 3,
- UserEntityId = 1
+ UserEntityPseudo = "Sha"
},
new ArticleUserEntity
{
ArticleEntityId = 2,
- UserEntityId = 3
+ UserEntityPseudo = "Sha"
}
);
}
diff --git a/Verax_API_EF/Verax_API_EF/StubbedContextLib/StubTest.cs b/Verax_API_EF/Verax_API_EF/StubbedContextLib/StubTest.cs
deleted file mode 100644
index 6e01d1f..0000000
--- a/Verax_API_EF/Verax_API_EF/StubbedContextLib/StubTest.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using Entities;
-using Model;
-
-namespace StubbedContextLib;
-
-public class StubTest
-{
- private List _article;
-
- public List StubArticle()
- {
- _article = new List
- {
- new Article
- {
- Id = 1,
- Title = "Test",
- Description = "Test",
- Author = "Test",
- DatePublished = "Test",
- LectureTime = 1
- }
- };
- return _article;
- }
-}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/Test_Console_EF/Entity_FrameWork.Article.db b/Verax_API_EF/Verax_API_EF/Test_Console_EF/Entity_FrameWork.Article.db
new file mode 100644
index 0000000..175a9e3
Binary files /dev/null and b/Verax_API_EF/Verax_API_EF/Test_Console_EF/Entity_FrameWork.Article.db differ
diff --git a/Verax_API_EF/Verax_API_EF/Test_Console_EF/Program.cs b/Verax_API_EF/Verax_API_EF/Test_Console_EF/Program.cs
deleted file mode 100644
index 5077f83..0000000
--- a/Verax_API_EF/Verax_API_EF/Test_Console_EF/Program.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-// See https://aka.ms/new-console-template for more information
-
-using DbContextLib;
-using Entities;
-
-addArticle();
-listArticle();
-
-// Allows to list all the articles from the db
-void listArticle()
-{
- using (var context = new LibraryContext())
- {
- var articles = context.ArticleSet;
- foreach (var article in articles)
- {
- Console.WriteLine($"{article.Author} - {article.Title} - {article.Description} - {article.DatePublished} - {article.LectureTime}");
- }
- }
-}
-
-
-// Allows to list all the articles from the db by author
-void listArticleByAuthor()
-{
- using (var context = new LibraryContext())
- {
- var articles = context.ArticleSet.Where(a => a.Author.Equals("Tony Fages"));
- foreach (var article in articles)
- {
- Console.WriteLine($"{article.Author} - {article.Title} - {article.Description} - {article.DatePublished} - {article.LectureTime}");
- }
- }
-}
-
-// Allows to add an article to the db
-void addArticle()
-{
- using (var context = new LibraryContext())
- {
- var article = new ArticleEntity
- {
- Title = "Louis is not sick anymore",
- Description = "Louis is not sick anymore, he is now healthy and happy",
- DatePublished = "16-02-2024",
- LectureTime = 1,
- Author = "Tony Fages"
- };
- context.ArticleSet.Add(article);
- context.SaveChanges();
- }
-}
-
-
-// Allows to modify an article from the db
-void modifyArticle()
-{
- using (var context = new LibraryContext())
- {
- var article = context.ArticleSet.Where(a => a.Author.Equals("Tom Smith"));
-
- foreach (var articles in article)
- {
- articles.Title = "Demain des l'aube";
- context.SaveChanges();
- }
- }
-}
-
-// Allows to delete an article from the db
-void deleteArticle()
-{
- using (var context = new LibraryContext())
- {
- var article = context.ArticleSet.Where(a => a.Author.Equals("M&M's Red"));
-
- foreach (var articles in article)
- {
- context.ArticleSet.Remove(articles);
- context.SaveChanges();
- }
- }
-}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/Test_Console_EF/Test_Console_EF.cs b/Verax_API_EF/Verax_API_EF/Test_Console_EF/Test_Console_EF.cs
new file mode 100644
index 0000000..df969d9
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/Test_Console_EF/Test_Console_EF.cs
@@ -0,0 +1,303 @@
+// See https://aka.ms/new-console-template for more information
+
+using DbContextLib;
+using Entities;
+
+//Article
+//addArticle();
+listArticle();
+//modifyArticle();
+//deleteArticle();
+//listArticleByAuthor();
+
+//Form
+//addForm();
+listForms();
+//updateForm();
+//deleteForm();
+
+//User
+//listUser();
+//addUser();
+//updateUser();
+//deleteUser();
+
+//ArticleUser
+//listArticleUser();
+//addArticleUser();
+//updateArticleUser();
+//deleteArticleUser();
+
+//FormUser
+listFormUser();
+//addFormUser();
+
+
+// Allows to list all the articles from the db
+void listArticle()
+{
+ using (var context = new LibraryContext())
+ {
+ var articles = context.ArticleSet;
+ foreach (var article in articles)
+ {
+ Console.WriteLine($"{article.Author} - {article.Title} - {article.Description} - {article.DatePublished} - {article.LectureTime}");
+ }
+ }
+}
+
+
+// Allows to list all the articles from the db by author
+void listArticleByAuthor()
+{
+ using (var context = new LibraryContext())
+ {
+ var articles = context.ArticleSet.Where(a => a.Author.Equals("Tony Fages"));
+ foreach (var article in articles)
+ {
+ Console.WriteLine($"{article.Author} - {article.Title} - {article.Description} - {article.DatePublished} - {article.LectureTime}");
+ }
+ }
+}
+
+// Allows to add an article to the db
+void addArticle()
+{
+ using (var context = new LibraryContext())
+ {
+ var article = new ArticleEntity
+ {
+ Title = "Louis is not sick anymore",
+ Description = "Louis is not sick anymore, he is now healthy and happy",
+ DatePublished = "16-02-2024",
+ LectureTime = 1,
+ Author = "Tony Fages"
+ };
+ context.ArticleSet.Add(article);
+ context.SaveChanges();
+ }
+}
+
+
+// Allows to modify an article from the db
+void modifyArticle()
+{
+ using (var context = new LibraryContext())
+ {
+ var article = context.ArticleSet.Where(a => a.Author.Equals("Tom Smith"));
+
+ foreach (var articles in article)
+ {
+ articles.Title = "Demain des l'aube";
+ context.SaveChanges();
+ }
+ }
+}
+
+// Allows to delete an article from the db
+void deleteArticle()
+{
+ using (var context = new LibraryContext())
+ {
+ var article = context.ArticleSet.Where(a => a.Author.Equals("M&M's Red"));
+
+ foreach (var articles in article)
+ {
+ context.ArticleSet.Remove(articles);
+ context.SaveChanges();
+ }
+ }
+}
+
+// Allow to get all forms
+void listForms()
+{
+ using (var context = new LibraryContext())
+ {
+ var forms = context.FormSet;
+ foreach (var form in forms)
+ {
+ Console.WriteLine($"{form.Id} - {form.Link} - {form.DatePublication} - {form.Theme} - {form.UserEntityPseudo}");
+ }
+ }
+}
+
+void addForm()
+{
+ using (var context = new LibraryContext())
+ {
+ var form = new FormEntity
+ {
+ Id = 5,
+ Theme = "Covid",
+ DatePublication = "16-02-2024",
+ Link = "https://www.covid.com",
+ UserEntityPseudo = "Sha"
+ };
+ context.FormSet.Add(form);
+ context.SaveChanges();
+ }
+}
+
+void updateForm()
+{
+ using (var context = new LibraryContext())
+ {
+ var form = context.FormSet.Where(f => f.Id.Equals(5));
+
+ foreach (var forms in form)
+ {
+ forms.Theme = "Demain des l'aube";
+ context.SaveChanges();
+ }
+ }
+}
+
+void deleteForm()
+{
+ using (var context = new LibraryContext())
+ {
+ var form = context.FormSet.Where(f => f.Id.Equals(5));
+
+ foreach (var forms in form)
+ {
+ context.FormSet.Remove(forms);
+ context.SaveChanges();
+ }
+ }
+}
+
+void listUser()
+{
+ using (var context = new LibraryContext())
+ {
+ var users = context.UserSet;
+ foreach (var user in users)
+ {
+ Console.WriteLine($" {user.Pseudo} - {user.Nom} - {user.Prenom} - {user.Mail} - {user.Role}");
+ }
+ }
+}
+
+void addUser()
+{
+ using (var context = new LibraryContext())
+ {
+ var user = new UserEntity
+ {
+ Nom = "Fages", Prenom = "Tony", Pseudo = "TonyF", Mail = "tony@gmail.com", Mdp = "1234", Role = "Admin"
+ };
+ context.UserSet.Add(user);
+ context.SaveChanges();
+ }
+ listUser();
+}
+
+void updateUser()
+{
+ using (var context = new LibraryContext())
+ {
+ var user = context.UserSet.Where(u => u.Pseudo.Equals("Sha"));
+
+ foreach (var users in user)
+ {
+ users.Nom = "Thomas";
+ context.SaveChanges();
+ }
+ }
+ listUser();
+}
+
+void deleteUser()
+{
+ using (var context = new LibraryContext())
+ {
+ var user = context.UserSet.Where(u => u.Pseudo.Equals("Sha"));
+
+ foreach (var users in user)
+ {
+ context.UserSet.Remove(users);
+ context.SaveChanges();
+ }
+ }
+ listUser();
+}
+
+void listArticleUser()
+{
+ using (var context = new LibraryContext())
+ {
+ var articleUsers = context.ArticleUserSet;
+ foreach (var articleUser in articleUsers)
+ {
+ Console.WriteLine($"{articleUser.ArticleEntityId} - {articleUser.UserEntityPseudo}");
+ }
+ }
+}
+
+void addArticleUser()
+{
+ using (var context = new LibraryContext())
+ {
+ var articleUser = new ArticleUserEntity
+ {
+ ArticleEntityId = 2,
+ UserEntityPseudo = "Sha"
+ };
+ context.ArticleUserSet.Add(articleUser);
+ context.SaveChanges();
+ }
+ listArticleUser();
+}
+
+void updateArticleUser()
+{
+ using (var context = new LibraryContext())
+ {
+ var articleUser = context.ArticleUserSet.FirstOrDefault(au => au.UserEntityPseudo.Equals("Sha"));
+ if (articleUser != null) articleUser.UserEntityPseudo = "Sha";
+ context.SaveChanges();
+ }
+ listArticleUser();
+}
+
+void deleteArticleUser()
+{
+ using (var context = new LibraryContext())
+ {
+ var articleUser = context.ArticleUserSet.Where(au => au.UserEntityPseudo.Equals(1)).Where(u => u.ArticleEntityId.Equals(1));
+
+ foreach (var articleUsers in articleUser)
+ {
+ context.ArticleUserSet.Remove(articleUsers);
+ context.SaveChanges();
+ }
+ }
+ listArticleUser();
+}
+
+void listFormUser()
+{
+ using (var context = new LibraryContext())
+ {
+ var formUsers = context.FormSet.Where(u => u.UserEntityPseudo.Equals(1));
+ foreach (var formUser in formUsers)
+ {
+ Console.WriteLine($"{formUser.UserEntityPseudo} - {formUser.Theme} - {formUser.Link}");
+ }
+ }
+}
+
+void addFormUser()
+{
+ using (var context = new LibraryContext())
+ {
+ var formUser = new FormEntity
+ {
+ UserEntityPseudo = "Sha",
+ };
+ context.FormSet.Add(formUser);
+ context.SaveChanges();
+ }
+}
+
diff --git a/Verax_API_EF/Verax_API_EF/Test_Console_EF/log.txt b/Verax_API_EF/Verax_API_EF/Test_Console_EF/log.txt
new file mode 100644
index 0000000..e69de29
diff --git a/Verax_API_EF/Verax_API_EF/TestsUnitaires/Properties/AssemblyInfo.cs b/Verax_API_EF/Verax_API_EF/TestsUnitaires/Properties/AssemblyInfo.cs
deleted file mode 100644
index c3f33a7..0000000
--- a/Verax_API_EF/Verax_API_EF/TestsUnitaires/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("TestsUnitaires")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("TestsUnitaires")]
-[assembly: AssemblyCopyright("Copyright © 2024")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("FF8AFA55-12FE-4856-A0A1-21344D366E12")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/TestsUnitaires/Tests.cs b/Verax_API_EF/Verax_API_EF/TestsUnitaires/Tests.cs
deleted file mode 100644
index f0b4fcb..0000000
--- a/Verax_API_EF/Verax_API_EF/TestsUnitaires/Tests.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using Xunit;
-
-namespace TestsUnitaires
-{
- public class Tests
- {
- [Fact]
- public void Test1()
- {
- Assert.True(true);
- }
- }
-}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/TestsUnitaires/TestsUnitaires.csproj b/Verax_API_EF/Verax_API_EF/TestsUnitaires/TestsUnitaires.csproj
deleted file mode 100644
index 6242cf4..0000000
--- a/Verax_API_EF/Verax_API_EF/TestsUnitaires/TestsUnitaires.csproj
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {FF8AFA55-12FE-4856-A0A1-21344D366E12}
- {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- Library
- Properties
- TestsUnitaires
- TestsUnitaires
- v4.8
- 512
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
- ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll
-
-
- ..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll
-
-
- ..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll
-
-
- ..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll
-
-
-
-
-
-
-
-
-
diff --git a/Verax_API_EF/Verax_API_EF/TestsUnitaires/packages.config b/Verax_API_EF/Verax_API_EF/TestsUnitaires/packages.config
deleted file mode 100644
index 69a4ec4..0000000
--- a/Verax_API_EF/Verax_API_EF/TestsUnitaires/packages.config
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/Unit_Test_EF/TestsArticleEntity.cs b/Verax_API_EF/Verax_API_EF/Unit_Test_EF/TestsArticleEntity.cs
new file mode 100644
index 0000000..7fd74b0
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/Unit_Test_EF/TestsArticleEntity.cs
@@ -0,0 +1,102 @@
+using DbContextLib;
+using Entities;
+using Microsoft.Data.Sqlite;
+using Microsoft.EntityFrameworkCore;
+
+namespace TestsUnitaires;
+
+public class TestsArticleEntity
+{
+ [Fact]
+ public void Add_Test()
+ {
+ var connection = new SqliteConnection("DataSource=:memory:");
+ connection.Open();
+
+ var options = new DbContextOptionsBuilder()
+ .UseSqlite(connection)
+ .Options;
+
+ using (var context = new LibraryContext(options))
+ {
+ context.Database.EnsureCreated();
+ ArticleEntity a1 = new ArticleEntity { Title = "Breaking News Elisabeth 2 Died", Description = "The queen of England died today at the age of 95", DatePublished = "2022-02-06", LectureTime = 2, Author = "Tom Smith" };
+ ArticleEntity a2 = new ArticleEntity { Title = "The new iPhone 15", Description = "The new iPhone 15 is out and it's the best phone ever", DatePublished = "2022-02-06", LectureTime = 3, Author = "Tom Smith" };
+ ArticleEntity a3 = new ArticleEntity { Title = "M&M's new recipe", Description = "M&M's new recipe is out and it's the best chocolate ever", DatePublished = "2022-02-06", LectureTime = 1, Author = "M&M's Red" };
+
+ context.ArticleSet.Add(a1);
+ context.ArticleSet.Add(a2);
+ context.ArticleSet.Add(a3);
+
+ context.SaveChanges();
+
+ Assert.Equal(3, context.ArticleSet.Count());
+ Assert.Equal("Tom Smith", context.ArticleSet.First().Author);
+ connection.Close();
+ }
+ }
+
+ [Fact]
+ public void Modify_Test()
+ {
+ var connection = new SqliteConnection("DataSource=:memory:");
+ connection.Open();
+
+ var options = new DbContextOptionsBuilder()
+ .UseSqlite(connection)
+ .Options;
+ using (var context = new LibraryContext(options))
+ {
+ context.Database.EnsureCreated();
+ ArticleEntity a1 = new ArticleEntity { Id = 1, Title = "Breaking News Elisabeth 2 Died", Description = "The queen of England died today at the age of 95", DatePublished = "2022-02-06", LectureTime = 2, Author = "Tom Smith" };
+ ArticleEntity a2 = new ArticleEntity { Id = 2, Title = "The new iPhone 15", Description = "The new iPhone 15 is out and it's the best phone ever", DatePublished = "2022-02-06", LectureTime = 3, Author = "Tom Smith" };
+ ArticleEntity a3 = new ArticleEntity { Id = 3, Title = "M&M's new recipe", Description = "M&M's new recipe is out and it's the best chocolate ever", DatePublished = "2022-02-06", LectureTime = 1, Author = "M&M's Red" };
+ context.ArticleSet.Add(a1);
+ context.ArticleSet.Add(a2);
+ context.ArticleSet.Add(a3);
+
+ context.SaveChanges();
+
+ var article = context.ArticleSet.First(a => a.Title.Equals("Breaking News Elisabeth 2 Died"));
+ article.Author = "Louis Laborie";
+ context.SaveChanges();
+ string persRemove = "Tom Smith";
+ string persNew = "Louis Laborie";
+ Assert.Equal(1, context.ArticleSet.Count(a => a.Author.Equals(persRemove)));
+ Assert.Equal(1, context.ArticleSet.Count(a => a.Author.Equals(persNew)));
+ connection.Close();
+ }
+ }
+
+ [Fact]
+ public void Remove_Test()
+ {
+ var connection = new SqliteConnection("DataSource=:memory:");
+ connection.Open();
+
+ var options = new DbContextOptionsBuilder()
+ .UseSqlite(connection)
+ .Options;
+ using (var context = new LibraryContext(options))
+ {
+ context.Database.EnsureCreated();
+ ArticleEntity a1 = new ArticleEntity { Id = 1, Title = "Breaking News Elisabeth 2 Died", Description = "The queen of England died today at the age of 95", DatePublished = "2022-02-06", LectureTime = 2, Author = "Tom Smith" };
+ ArticleEntity a2 = new ArticleEntity { Id = 2, Title = "The new iPhone 15", Description = "The new iPhone 15 is out and it's the best phone ever", DatePublished = "2022-02-06", LectureTime = 3, Author = "Tom Smith" };
+ ArticleEntity a3 = new ArticleEntity { Id = 3, Title = "M&M's new recipe", Description = "M&M's new recipe is out and it's the best chocolate ever", DatePublished = "2022-02-06", LectureTime = 1, Author = "M&M's Red" };
+
+ context.Add(a1);
+ context.Add(a2);
+ context.Add(a3);
+
+ context.SaveChanges();
+
+ var article = context.ArticleSet.First(a => a.Title.Equals("Breaking News Elisabeth 2 Died"));
+ context.Remove(article);
+ context.SaveChanges();
+ Assert.Equal(2, context.ArticleSet.Count());
+ Assert.Equal(0, context.ArticleSet.Count(a => a.Title.Equals("Breaking News Elisabeth 2 Died")));
+ connection.Close();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/Unit_Test_EF/TestsUserEntity.cs b/Verax_API_EF/Verax_API_EF/Unit_Test_EF/TestsUserEntity.cs
new file mode 100644
index 0000000..4119245
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/Unit_Test_EF/TestsUserEntity.cs
@@ -0,0 +1,182 @@
+using DbContextLib;
+using Entities;
+using Microsoft.Data.Sqlite;
+using Microsoft.EntityFrameworkCore;
+
+namespace Tests;
+
+public class TestsUserEntity
+{
+ [Fact]
+ public void Add_Test()
+ {
+ var connection = new SqliteConnection("DataSource=:memory:");
+ connection.Open();
+
+ var options = new DbContextOptionsBuilder()
+ .UseSqlite(connection)
+ .Options;
+
+ using (var context = new LibraryContext(options))
+ {
+ context.Database.EnsureCreated();
+ UserEntity u1 = new UserEntity
+ {
+ Pseudo = "Tofgasy", Prenom = "Tony", Nom = "Fages", Mail = "he@gmail.com", Mdp = "1234", Role = "Admin"
+ };
+ UserEntity u2 = new UserEntity
+ {
+ Pseudo = "Blizzard", Prenom = "Louis", Nom = "Laborie", Mail = "he@gmail.com", Mdp = "1234",
+ Role = "Admin"
+ };
+ UserEntity u3 = new UserEntity
+ {
+ Pseudo = "TomS", Prenom = "Tom", Nom = "Smith", Mail = "TomS@gmail.com", Mdp = "1234", Role = "User"
+ };
+ UserEntity u4 = new UserEntity
+ {
+ Pseudo = "Siwa", Prenom = "Jean", Nom = "Marcillac", Mail = "occitan@gmail.com", Mdp = "1234",
+ Role = "Amin"
+ };
+ UserEntity u5 = new UserEntity
+ {
+ Pseudo = "Sha", Prenom = "Shana", Nom = "Cascarra", Mail = "shacas@gmail.com", Mdp = "1234",
+ Role = "Modérator"
+ };
+ UserEntity u6 = new UserEntity
+ {
+ Pseudo = "NoaSil", Prenom = "Noa", Nom = "Sillard", Mail = "noaSillar@gmail.com", Mdp = "1234",
+ Role = "Admin"
+ };
+ context.UserSet.Add(u1);
+ context.UserSet.Add(u2);
+ context.UserSet.Add(u3);
+ context.UserSet.Add(u4);
+ context.UserSet.Add(u5);
+ context.UserSet.Add(u6);
+ context.SaveChanges();
+
+ Assert.Equal(6, context.UserSet.Count());
+ Assert.Equal("Blizzard", context.UserSet.First().Pseudo);
+ connection.Close();
+ }
+ }
+
+ [Fact]
+ public void Modify_Test()
+ {
+ var connection = new SqliteConnection("DataSource=:memory:");
+ connection.Open();
+
+ var options = new DbContextOptionsBuilder()
+ .UseSqlite(connection)
+ .Options;
+ using (var context = new LibraryContext(options))
+ {
+ context.Database.EnsureCreated();
+ UserEntity u1 = new UserEntity
+ {
+ Pseudo = "Tofgasy", Prenom = "Tony", Nom = "Fages", Mail = "he@gmail.com", Mdp = "1234", Role = "Admin"
+ };
+ UserEntity u2 = new UserEntity
+ {
+ Pseudo = "Blizzard", Prenom = "Louis", Nom = "Laborie", Mail = "he@gmail.com", Mdp = "1234",
+ Role = "Admin"
+ };
+ UserEntity u3 = new UserEntity
+ {
+ Pseudo = "TomS", Prenom = "Tom", Nom = "Smith", Mail = "TomS@gmail.com", Mdp = "1234", Role = "User"
+ };
+ UserEntity u4 = new UserEntity
+ {
+ Pseudo = "Siwa", Prenom = "Jean", Nom = "Marcillac", Mail = "occitan@gmail.com", Mdp = "1234",
+ Role = "Amin"
+ };
+ UserEntity u5 = new UserEntity
+ {
+ Pseudo = "Sha", Prenom = "Shana", Nom = "Cascarra", Mail = "shacas@gmail.com", Mdp = "1234",
+ Role = "Modérator"
+ };
+ UserEntity u6 = new UserEntity
+ {
+ Pseudo = "NoaSil", Prenom = "Noa", Nom = "Sillard", Mail = "noaSillar@gmail.com", Mdp = "1234",
+ Role = "Admin"
+ };
+ context.UserSet.Add(u1);
+ context.UserSet.Add(u2);
+ context.UserSet.Add(u3);
+ context.UserSet.Add(u4);
+ context.UserSet.Add(u5);
+ context.UserSet.Add(u6);
+ context.SaveChanges();
+
+ var user = context.UserSet.First(u => u.Pseudo.Equals("Tofgasy"));
+ user.Prenom = "Tof";
+ context.SaveChanges();
+ string persRemove = "Tony";
+ string persNew = "Tof";
+ Assert.Equal(1, context.UserSet.Count(u => u.Prenom.Equals(persNew)));
+ Assert.Equal(0, context.UserSet.Count(u => u.Prenom.Equals(persRemove)));
+ connection.Close();
+
+ }
+ }
+
+ [Fact]
+ public void Remove_Test()
+ {
+ var connection = new SqliteConnection("DataSource=:memory:");
+ connection.Open();
+
+ var options = new DbContextOptionsBuilder()
+ .UseSqlite(connection)
+ .Options;
+ using (var context = new LibraryContext(options))
+ {
+ context.Database.EnsureCreated();
+ UserEntity u1 = new UserEntity
+ {
+ Pseudo = "Tofgasy", Prenom = "Tony", Nom = "Fages", Mail = "he@gmail.com", Mdp = "1234", Role = "Admin"
+ };
+ UserEntity u2 = new UserEntity
+ {
+ Pseudo = "Blizzard", Prenom = "Louis", Nom = "Laborie", Mail = "he@gmail.com", Mdp = "1234",
+ Role = "Admin"
+ };
+ UserEntity u3 = new UserEntity
+ {
+ Pseudo = "TomS", Prenom = "Tom", Nom = "Smith", Mail = "TomS@gmail.com", Mdp = "1234", Role = "User"
+ };
+ UserEntity u4 = new UserEntity
+ {
+ Pseudo = "Siwa", Prenom = "Jean", Nom = "Marcillac", Mail = "occitan@gmail.com", Mdp = "1234",
+ Role = "Amin"
+ };
+ UserEntity u5 = new UserEntity
+ {
+ Pseudo = "Sha", Prenom = "Shana", Nom = "Cascarra", Mail = "shacas@gmail.com", Mdp = "1234",
+ Role = "Modérator"
+ };
+ UserEntity u6 = new UserEntity
+ {
+ Pseudo = "NoaSil", Prenom = "Noa", Nom = "Sillard", Mail = "noaSillar@gmail.com", Mdp = "1234",
+ Role = "Admin"
+ };
+ context.UserSet.Add(u1);
+ context.UserSet.Add(u2);
+ context.UserSet.Add(u3);
+ context.UserSet.Add(u4);
+ context.UserSet.Add(u5);
+ context.UserSet.Add(u6);
+ context.SaveChanges();
+
+ Assert.Equal(6, context.UserSet.Count());
+ var user = context.UserSet.First(u => u.Pseudo.Equals("Tofgasy"));
+ context.Remove(user);
+ context.SaveChanges();
+ Assert.Equal(5, context.UserSet.Count());
+ Assert.Equal(0, context.UserSet.Count(u => u.Pseudo.Equals("Tofgasy")));
+ connection.Close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/Unit_Test_EF/Unit_Test_EF.csproj b/Verax_API_EF/Verax_API_EF/Unit_Test_EF/Unit_Test_EF.csproj
new file mode 100644
index 0000000..fc4de9b
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/Unit_Test_EF/Unit_Test_EF.csproj
@@ -0,0 +1,35 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+ false
+ true
+ TestsUnitaires
+
+
+
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Verax_API_EF/Verax_API_EF/Verax_API_EF.sln b/Verax_API_EF/Verax_API_EF/Verax_API_EF.sln
index 2b1c5b3..473c412 100644
--- a/Verax_API_EF/Verax_API_EF/Verax_API_EF.sln
+++ b/Verax_API_EF/Verax_API_EF/Verax_API_EF.sln
@@ -1,24 +1,33 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Console_EF", "Test_Console_EF\Test_Console_EF.csproj", "{E27E2617-28A1-4675-B12B-89430582C05E}"
+# Visual Studio Version 17
+VisualStudioVersion = 17.8.34525.116
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test_Console_EF", "Test_Console_EF\Test_Console_EF.csproj", "{E27E2617-28A1-4675-B12B-89430582C05E}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entities", "Entities\Entities.csproj", "{40BD34D7-3F07-410A-BC04-2A5B09E758C0}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entities", "Entities\Entities.csproj", "{40BD34D7-3F07-410A-BC04-2A5B09E758C0}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbContextLib", "DbContextLib\DbContextLib.csproj", "{F94BEE1F-302F-4654-8D85-AD41E0BACD03}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DbContextLib", "DbContextLib\DbContextLib.csproj", "{F94BEE1F-302F-4654-8D85-AD41E0BACD03}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubbedContextLib", "StubbedContextLib\StubbedContextLib.csproj", "{F1B4BCE5-8DE7-4EFB-8BC1-D7E04EA75302}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubbedContextLib", "StubbedContextLib\StubbedContextLib.csproj", "{F1B4BCE5-8DE7-4EFB-8BC1-D7E04EA75302}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API_DbDataManager", "API_DbDataManager\API_DbDataManager.csproj", "{FBA0CF18-7488-4088-A7C5-5D2071D19CCB}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API_DbDataManager", "API_DbDataManager\API_DbDataManager.csproj", "{FBA0CF18-7488-4088-A7C5-5D2071D19CCB}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API_Services", "API_Services\API_Services.csproj", "{4FB7D286-B583-44BC-BB79-4AE3058AFEDE}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API_Services", "API_Services\API_Services.csproj", "{4FB7D286-B583-44BC-BB79-4AE3058AFEDE}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API_Model", "API_Model\API_Model.csproj", "{F09B566E-8D25-4D70-B9F0-99E6969D4D1F}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API_Model", "API_Model\API_Model.csproj", "{F09B566E-8D25-4D70-B9F0-99E6969D4D1F}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API_Mapping", "API_Mapping\API_Mapping.csproj", "{BECFAD2C-E442-4300-8121-5AE6610B92DF}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API_Mapping", "API_Mapping\API_Mapping.csproj", "{BECFAD2C-E442-4300-8121-5AE6610B92DF}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{96FDB5DE-6707-4856-94CD-EFAF0C7CEB4B}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj", "{96FDB5DE-6707-4856-94CD-EFAF0C7CEB4B}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API", "API\API.csproj", "{6AACD337-70A0-429B-979C-1B1E004BF2E0}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API", "API\API.csproj", "{6AACD337-70A0-429B-979C-1B1E004BF2E0}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unit_Test_EF", "Unit_Test_EF\Unit_Test_EF.csproj", "{C1982C7C-AE09-4E96-B1A9-B6ADE4097452}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API_Unit_Test", "API_Unit_Test\API_Unit_Test.csproj", "{B3B9C0F5-98A3-438B-A22A-ECFF33DA8F23}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API_Tests_Console", "API_Tests_Console\API_Tests_Console.csproj", "{EEB45245-5B65-4C99-A2B4-942991AE5F1A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -66,5 +75,20 @@ Global
{6AACD337-70A0-429B-979C-1B1E004BF2E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6AACD337-70A0-429B-979C-1B1E004BF2E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6AACD337-70A0-429B-979C-1B1E004BF2E0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C1982C7C-AE09-4E96-B1A9-B6ADE4097452}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C1982C7C-AE09-4E96-B1A9-B6ADE4097452}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C1982C7C-AE09-4E96-B1A9-B6ADE4097452}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C1982C7C-AE09-4E96-B1A9-B6ADE4097452}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B3B9C0F5-98A3-438B-A22A-ECFF33DA8F23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B3B9C0F5-98A3-438B-A22A-ECFF33DA8F23}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B3B9C0F5-98A3-438B-A22A-ECFF33DA8F23}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B3B9C0F5-98A3-438B-A22A-ECFF33DA8F23}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EEB45245-5B65-4C99-A2B4-942991AE5F1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EEB45245-5B65-4C99-A2B4-942991AE5F1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EEB45245-5B65-4C99-A2B4-942991AE5F1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EEB45245-5B65-4C99-A2B4-942991AE5F1A}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
diff --git a/Verax_API_EF/Verax_API_EF/Verax_API_EF/.idea/.idea.Verax_API_EF.dir/.idea/.gitignore b/Verax_API_EF/Verax_API_EF/Verax_API_EF/.idea/.idea.Verax_API_EF.dir/.idea/.gitignore
new file mode 100644
index 0000000..477ae27
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/Verax_API_EF/.idea/.idea.Verax_API_EF.dir/.idea/.gitignore
@@ -0,0 +1,15 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Rider ignored files
+/modules.xml
+/projectSettingsUpdater.xml
+/.idea.Verax_API_EF.iml
+/contentModel.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# GitHub Copilot persisted chat sessions
+/copilot/chatSessions
diff --git a/Verax_API_EF/Verax_API_EF/Verax_API_EF/.idea/.idea.Verax_API_EF.dir/.idea/indexLayout.xml b/Verax_API_EF/Verax_API_EF/Verax_API_EF/.idea/.idea.Verax_API_EF.dir/.idea/indexLayout.xml
new file mode 100644
index 0000000..7b08163
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/Verax_API_EF/.idea/.idea.Verax_API_EF.dir/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Verax_API_EF/Verax_API_EF/Verax_API_EF/.idea/.idea.Verax_API_EF.dir/.idea/vcs.xml b/Verax_API_EF/Verax_API_EF/Verax_API_EF/.idea/.idea.Verax_API_EF.dir/.idea/vcs.xml
new file mode 100644
index 0000000..b2bdec2
--- /dev/null
+++ b/Verax_API_EF/Verax_API_EF/Verax_API_EF/.idea/.idea.Verax_API_EF.dir/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file