Compare commits

..

109 Commits

Author SHA1 Message Date
Clement.Ferrere 44920d954f Merge pull request 'update_pour_documentation à faire en 3ème' (#17) from update_pour_documentation into develop 3 years ago
Clement.Ferrere f7123b577e Merge branch 'develop' into update_pour_documentation 3 years ago
Clement.Ferrere ccf9a24049 Merge pull request 'delete_cascade_collabs à faire en 2ème' (#16) from delete_cascade_collabs into develop 3 years ago
Clement.Ferrere 73a5659408 Merge branch 'develop' into delete_cascade_collabs 3 years ago
Clement.Ferrere beb841f5fc Merge pull request 'update des csproj et des packages nuggets' (#15) from update_packages into develop 3 years ago
Clement.Ferrere c7f4b63f81 Merge branch 'develop' into update_pour_documentation 3 years ago
Clement.Ferrere 48d4eb15a6 Merge branch 'develop' into delete_cascade_collabs 3 years ago
Clement FERRERE 5a0a0d113a update suite commentaire merge 3 years ago
Clement.Ferrere 54a1990c44 Merge branch 'develop' into update_packages 3 years ago
Clement FERRERE 8a09441842 up doc 3 years ago
Clement FERRERE 7b8fd4fd54 delete cascades des entités liées à un collaborateur 3 years ago
Alexandre Ruiz 6529c1317c Merge pull request 'fix_periode_essai à faire après le merge de rework_referencement' (#14) from fix_periode_essai into develop 3 years ago
Alexandre Ruiz 70aed9c536 Merge pull request 'rework_referencement' (#13) from rework_referencement into develop 3 years ago
Clement FERRERE d202eac901 update des csproj 3 years ago
Clement FERRERE 4fe26e52f6 ajout des champs non obligatoires et de l'issue indéterminée 3 years ago
Clement FERRERE a97d30e3d8 fix MR 3 years ago
Clement FERRERE fc255f0709 up settings 3 years ago
Clement FERRERE 988a48a8cf rework referencement 3 years ago
Clement.Ferrere 2b92cb2fb2 Merge pull request 'date de départ non obligatoire dans develop' (#12) from refonte_agence_bu into develop 3 years ago
Clement.Ferrere 665108cbb9 Merge branch 'develop' into refonte_agence_bu 3 years ago
Clement FERRERE 0a4cb4a808 date de départ non obligatoire 3 years ago
Clement.Ferrere d1540dae79 Merge pull request 'refonte_agence_bu' (#11) from refonte_agence_bu into develop 3 years ago
Clement FERRERE 00d711b936 fix de la gestion de l'unicité des mails apside pour l'update d'un collaborateur 3 years ago
Clement FERRERE 826dc37379 fix gestion unicité mail apside 3 years ago
Clement FERRERE e9cb320e4a Gestion de l'unicité des adresses mails 3 years ago
Clement FERRERE bc6daab6d1 refonte complète de l'agence et de la BU (inversion) 3 years ago
Clement.Ferrere 75d62373ac Merge pull request 'fix de l'update des entités' (#10) from fix_update into develop 3 years ago
Clement FERRERE a49c9ec876 fix de l'update des entités 3 years ago
Clement FERRERE ae3f2beb05 utilisation de la DB locale, pas de docker 3 years ago
Clement FERRERE f560a6dbe5 suppression de docker-compose et documentation, recentralisationn sur GIT dédié 3 years ago
Clement FERRERE a4f8723037 ajout de 8083 pour le docker compose dans le CORS 3 years ago
Clement FERRERE abbde8d610 docker fonctionne vraiment, fix du problème dans l'initialisation de la DB 3 years ago
Clement FERRERE bd15f0aca3 simplification script init 3 years ago
Clement FERRERE 9f12cc4a39 fix nommage des controllers 3 years ago
Clement FERRERE 43d6c0f25b ajout de données initiales 3 years ago
Clement.Ferrere c71ed26a24 Merge pull request 'dockerisation' (#9) from dockerisation into develop 3 years ago
Clement.Ferrere 2b1d16cf70 Merge branch 'develop' into dockerisation 3 years ago
Clement FERRERE ef2a5141d9 CORS sur 8082 pour docker 3 years ago
Clement FERRERE 2aeb4b9aac Merge branch 'develop' of https://gitea.ci.apside-top.fr/Clement.Ferrere/Collaborateur_Epa_Back into develop 3 years ago
Clement FERRERE 28dfb754f5 push de la doc locale 3 years ago
Clement.Ferrere c377dffe71 Mise à jour de 'README.md' 3 years ago
Clement.Ferrere 2ed8ae8fb0 Mise à jour de 'README.md' 3 years ago
Clement.Ferrere 3ddaf7738d Mise à jour de 'LOCAL.md' 3 years ago
Clement.Ferrere ba831fd2f4 Mise à jour de 'LOCAL.md' 3 years ago
Clement.Ferrere 93c0b98102 Mise à jour de 'LOCAL.md' 3 years ago
Clement.Ferrere cfa6ed5633 Mise à jour de 'LOCAL.md' 3 years ago
Clement.Ferrere ed4e4dd1a1 création de LOCAL.md 3 years ago
Clement.Ferrere b558aff711 update readme 3 years ago
Clement FERRERE 84ec30f541 Création script SQL + fonctionnement docker-compose 3 years ago
Clement FERRERE 514bacd4f6 dockerisation fonctionnelle mais création de la base à prévoir -> script à créer et settings à vérifier 3 years ago
Clement FERRERE 1b65998d19 Première tentative de dockerisation, docker compose ne fonctionne pas mais le conteneur de l'api se lance de manière correctement indépendante 3 years ago
Clement FERRERE 7c71bba88c Ajout des annotations primary key et table dans les entités 3 years ago
Alexandre Ruiz ebe71c645a Merge branch 'FixUtilisationBdd' into develop 3 years ago
Alexandre Ruiz c35603e4eb Merge 3 years ago
Alexandre Ruiz d7e4795320 Merge pull request 'Mise en place d'entités' (#4) from task/tu into develop 3 years ago
Alexandre Ruiz 038cf2b909 Merge 3 years ago
Alexandre Ruiz a2d1965ca7 Fix merge 3 years ago
Alexandre Ruiz 958e57db93 Merge 3 years ago
Alexandre Ruiz 285e20225a restriction T 3 years ago
Clement FERRERE 3ec4368324 Mise en place de l'entité Technologie 3 years ago
Clement FERRERE eba5a08fe8 Ajout entité Fonction 3 years ago
Clement FERRERE fa4e6668ff ajout de l'entité businessUnit 3 years ago
Clement FERRERE e2123679b7 ajout du context agence pour fonctionnement DB 3 years ago
Clement FERRERE 14ffece7b1 Ajout d'un context pour les agences 3 years ago
Alexandre Ruiz 16059ff5d0 TU générique sur Controller 3 years ago
Alexandre Ruiz f29bb823b5 Fix type 3 years ago
Alexandre Ruiz 84e6c3b08c clean code + add interface 3 years ago
Alexandre Ruiz 24983a0fa0 MAJ packages 3 years ago
Alexandre Ruiz 9bb52cfada Rename file 3 years ago
Alexandre Ruiz 418b4cd972 clean code ReSharper 3 years ago
Alexandre Ruiz f44f34fdec Merge 3 years ago
Alexandre Ruiz 09f21deee3 Merge pull request 'FixUtilisationBdd Merge into develop' (#3) from FixUtilisationBdd into develop 3 years ago
Clement FERRERE 43f790493d Multiples fix pour permettre au front d'utiliser l'API 3 years ago
Alexandre Ruiz eecdf57f36 Periode essaie 3 years ago
Alexandre Ruiz d683ef85e7 Fonction CRUD 3 years ago
Alexandre Ruiz 61d64beaea refacto + business unit 3 years ago
Clement FERRERE 209760275b Fix de l'utilisation de la BDD, reste à revoir le fonctionnement du parrainage et des référents 3 years ago
Alexandre Ruiz 5be72f3930 Merge pull request 'MR creationDtoSql vers develop' (#2) from creationDtoSql into develop 3 years ago
Alexandre Ruiz e2499173f2 Merge branch 'develop' into creationDtoSql 3 years ago
Clement FERRERE 1071204c1b fix route put base controller 3 years ago
Clement FERRERE b7064ccc44 Ajout des agences avec généricité 3 years ago
Clement FERRERE ad64563055 Fix Nommage des routes add et update 3 years ago
Clement FERRERE a3f46a1348 Fix Register en Singleton pour conservation des Fake Data pendant l'exécution 3 years ago
Clement FERRERE f495bd019e Fix "Utilisation des type unsigned dans la couche API + AppSvc" 3 years ago
Clement FERRERE 01c4ea7120 Fix "Nommage des routes CRUD" 3 years ago
Clement FERRERE ecacc497eb Fix "Route UPDATE/DELETE avec id" 3 years ago
Clement FERRERE 62f0c210a9 Refacto + "Valider les types directement dans l'URL (quand possible)" 3 years ago
Clement FERRERE 4c7647ac27 Code Cleanup 3 years ago
Clement FERRERE 34a5c4783f Collaborateurs complets 3 years ago
Clement FERRERE 09ff256ca7 Généricité complète, TODO fixed. 3 years ago
Clement FERRERE e5c9c3a85e Refacto + Generic repos et service complet 3 years ago
Clement FERRERE 1191ca7371 Delete et update generic + collaborateur services 3 years ago
Clement FERRERE f91c1101cd Add Generic Services fonctionnel, testé avec collaborateurController 3 years ago
Clement FERRERE f1de70eafa Generic get by id, refacto par Alex 3 years ago
Clement FERRERE e8beae3b90 Avancement Controller et Services Collaborateur 3 years ago
Clement FERRERE 15d9b039fa GetAll fonctionnel avec Fake Datas 3 years ago
Clement FERRERE faf2cccee7 Ajout de controller, service et repository + généricité + fix de program et startup et settings 3 years ago
Clement FERRERE 7b7bd77e6e Création des interfaces pour autres repos. Agence incomplète, Période Essai à voir 3 years ago
Clement FERRERE fcdff5d566 Création du repository collaborateur selon les routes de la doc swagger. 3 years ago
Alexandre Ruiz e187e9a687 Merge pull request 'creationDtoSql' (#1) from creationDtoSql into develop 3 years ago
Clement FERRERE 35cdc15f32 correction gitignore 3 years ago
Clement FERRERE b363f3184b modififcation gitignore 3 years ago
Clement FERRERE c07ec70fcd Corrections de la PR 3 years ago
Clement FERRERE 363999950d Correction Foreign Key PeriodeEssai 3 years ago
Clement FERRERE f7ef2e912d Corrections de nommage 3 years ago
Clement FERRERE cf08ebda82 Corrections de nommage et ajout de l'adresse oublié dans le collaborateur 3 years ago
Clement FERRERE be92114591 Création des projets et des DTOs SQL 3 years ago
Clement FERRERE ef5d596d43 Création du script correspondant à la BDD 3 years ago
Clement FERRERE 3812a18162 Création de la solution 3 years ago
  1. 17
      .gitignore
  2. 64
      Collaborateur_Epa_Back/espacecollab.backend.api.tests/BaseControllerTest.cs
  3. 24
      Collaborateur_Epa_Back/espacecollab.backend.api.tests/CollaborateursControllerTest.cs
  4. 28
      Collaborateur_Epa_Back/espacecollab.backend.api.tests/espacecollab.backend.api.tests.csproj
  5. 25
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/AgencesController.cs
  6. 68
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/BaseController.cs
  7. 16
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/BusinessUnitsController.cs
  8. 94
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/CollaborateursController.cs
  9. 12
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/FonctionsController.cs
  10. 17
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/IBaseController.cs
  11. 11
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/PeriodeEssaisController.cs
  12. 13
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/ReferencementsController.cs
  13. 12
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/TechnologiesController.cs
  14. 29
      Collaborateur_Epa_Back/espacecollab.backend.api/Dockerfile
  15. 16
      Collaborateur_Epa_Back/espacecollab.backend.api/Program.cs
  16. 38
      Collaborateur_Epa_Back/espacecollab.backend.api/Properties/launchSettings.json
  17. 42
      Collaborateur_Epa_Back/espacecollab.backend.api/Register.cs
  18. 57
      Collaborateur_Epa_Back/espacecollab.backend.api/Startup.cs
  19. 14
      Collaborateur_Epa_Back/espacecollab.backend.api/appsettings.json
  20. 26
      Collaborateur_Epa_Back/espacecollab.backend.api/espacecollab.backend.api.csproj
  21. 8
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/AgenceApiDto.cs
  22. 8
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/BusinessUnitApiDto.cs
  23. 10
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/CollaborateurApiDto.cs
  24. 8
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/FonctionApiDto.cs
  25. 6
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Interfaces/IGenericIdApiDto.cs
  26. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/AgenceMapper.cs
  27. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/BusinessUnitMapper.cs
  28. 22
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/CollaborateurMapper.cs
  29. 29
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/EnumGenreMapper.cs
  30. 31
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/EnumStatutMapper.cs
  31. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/FonctionMapper.cs
  32. 22
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/PeriodeEssaiMapper.cs
  33. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/ReferencementMapper.cs
  34. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/TechnologieMapper.cs
  35. 9
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/PeriodeEssaiApiDto.cs
  36. 12
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/ReferencementApiDto.cs
  37. 8
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/TechnologieApiDto.cs
  38. 8
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Values/EnumGenreApi.cs
  39. 11
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Values/EnumIssueApi.cs
  40. 9
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Values/EnumStatutApi.cs
  41. 13
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/espacecollab.backend.appservices.dtos.csproj
  42. 16
      Collaborateur_Epa_Back/espacecollab.backend.appservices.interfaces/IGenericsServices.cs
  43. 14
      Collaborateur_Epa_Back/espacecollab.backend.appservices.interfaces/espacecollab.backend.appservices.interfaces.csproj
  44. 22
      Collaborateur_Epa_Back/espacecollab.backend.appservices/AgenceService.cs
  45. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices/BusinessUnitService.cs
  46. 100
      Collaborateur_Epa_Back/espacecollab.backend.appservices/CollaborateursService.cs
  47. 14
      Collaborateur_Epa_Back/espacecollab.backend.appservices/FonctionService.cs
  48. 66
      Collaborateur_Epa_Back/espacecollab.backend.appservices/GenericsServices.cs
  49. 14
      Collaborateur_Epa_Back/espacecollab.backend.appservices/PeriodeEssaiService.cs
  50. 18
      Collaborateur_Epa_Back/espacecollab.backend.appservices/ReferencementService.cs
  51. 14
      Collaborateur_Epa_Back/espacecollab.backend.appservices/TechnologieServices.cs
  52. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices/espacecollab.backend.appservices.csproj
  53. 16
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeAgenceRepository.cs
  54. 21
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeBusinessUnitRepository.cs
  55. 35
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeCollaborateurRepository.cs
  56. 16
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeFonctionRepository.cs
  57. 17
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakePeriodeEssaiRepository.cs
  58. 48
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/GenericFakeRepository.cs
  59. 14
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/espacecollab.backend.infrastructure.fake.csproj
  60. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IAgenceRepository.cs
  61. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IBusinessUnitRepository.cs
  62. 9
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/ICollaborateurRepository.cs
  63. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IFonctionRepository.cs
  64. 12
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IGenericRepository.cs
  65. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IPeriodeEssaiRepository.cs
  66. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IProjetRepository.cs
  67. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IReferencementRepository.cs
  68. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/ITechnologieRepository.cs
  69. 13
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/espacecollab.backend.infrastructure.interfaces.csproj
  70. 28
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/AgenceSqlDto.cs
  71. 26
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/BusinessUnitSqlDto.cs
  72. 21
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurAppartientBusinessUnitSqlDto.cs
  73. 22
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurCollaboreProjetSqlDto.cs
  74. 20
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurEstFonctionSqlDto.cs
  75. 54
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurSqlDto.cs
  76. 28
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/FonctionSqlDto.cs
  77. 6
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Interfaces/IGenericIdSqlDto.cs
  78. 37
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/PeriodeEssaiSqlDto.cs
  79. 33
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/ProjetSqlDto.cs
  80. 20
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/ProjetUtiliseTechnologieSqlDto.cs
  81. 31
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/ReferencementSqlDto.cs
  82. 20
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/SiteDeveloppeProjetSqlDto.cs
  83. 29
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/SiteSqlDto.cs
  84. 25
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/TechnologieSqlDto.cs
  85. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Values/EnumGenreSql.cs
  86. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Values/EnumIssueSql.cs
  87. 9
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Values/EnumStatutSql.cs
  88. 9
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/espacecollab.backend.infrastructure.sql.dtos.csproj
  89. 53
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/MainDbContext.cs
  90. 13
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Options/SqlOption.cs
  91. 14
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/AgenceSqlRepository.cs
  92. 13
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/BusinessUnitSqlRepository.cs
  93. 18
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/CollaborateurSqlRepository.cs
  94. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/FonctionSqlRepository.cs
  95. 52
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/GenericSqlRepository.cs
  96. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/PeriodeEssaiSqlRepository.cs
  97. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/ReferencementSqlRepository.cs
  98. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/TechnologieSqlRepository.cs
  99. 161
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/db/db_1_0_0.sql
  100. 18
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/espacecollab.backend.infrastructure.sql.csproj
  101. Some files were not shown because too many files have changed in this diff Show More

17
.gitignore vendored

@ -1,4 +1,3 @@
# ---> VisualStudio
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
@ -208,7 +207,7 @@ PublishScripts/
*.nuget.targets
# Nuget personal access tokens and Credentials
nuget.config
# nuget.config
# Microsoft Azure Build Output
csx/
@ -388,14 +387,6 @@ FodyWeavers.xsd
.idea/
*.sln.iml
# ---> VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
appsettings.Development.json
*.Development
*.Development.json

@ -0,0 +1,64 @@
using System.Collections.Generic;
using espacecollab.backend.api.Controllers;
using espacecollab.backend.appservices.dtos.Interfaces;
using FluentAssertions;
using Microsoft.AspNetCore.Mvc;
using Xunit;
namespace espacecollab.backend.api.tests;
public abstract class BaseControllerTest<T, TO> where T : IBaseController<TO>
where TO : class, IGenericIdApiDto
{
protected T Controller { get; set; }
protected TO NewApiDo { get; set; }
protected TO UpdateApiDo { get; set; }
[Fact]
public void GetAllTest()
{
ActionResult<IEnumerable<TO>> actionResult = Controller.GetAll();
OkObjectResult result = actionResult.Result.Should().BeOfType<OkObjectResult>().Subject;
result.Value.Should().BeOfType<List<TO>>();
}
[Fact]
public void GetByIdTest()
{
uint id = 1;
ActionResult<TO> actionResult = Controller.GetById(id);
OkObjectResult result = actionResult.Result.Should().BeOfType<OkObjectResult>().Subject;
result.Value.Should().BeOfType<TO>();
}
[Fact]
public void AddTest()
{
ActionResult<TO> actionResult = Controller.Add(NewApiDo);
OkObjectResult result = actionResult.Result.Should().BeOfType<OkObjectResult>().Subject;
result.Value.Should().BeOfType<TO>().Subject.Id.Should().NotBe(0);
}
[Fact]
public void DeleteTest()
{
uint id = 1;
ActionResult<TO> actionResult = Controller.Delete(id);
actionResult.Result.Should().BeOfType<OkResult>();
}
[Fact]
public void UpdateTest()
{
ActionResult<TO> actionResult = Controller.Update(UpdateApiDo.Id, UpdateApiDo);
OkObjectResult result = actionResult.Result.Should().BeOfType<OkObjectResult>().Subject;
result.Value.Should().BeOfType<TO>().Subject.Id.Should().Be(UpdateApiDo.Id);
}
}

@ -0,0 +1,24 @@
using espacecollab.backend.api.Controllers;
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
using espacecollab.backend.appservices.dtos.Values;
using espacecollab.backend.infrastructure.fake;
using System;
namespace espacecollab.backend.api.tests;
public class CollaborateursControllerTest : BaseControllerTest<CollaborateursController, CollaborateurApiDto>
{
public CollaborateursControllerTest()
{
Controller = new CollaborateursController(new CollaborateursService(new FakeCollaborateurRepository()));
NewApiDo = new CollaborateurApiDto(0, "Dupont", "Jean", new DateTime(1980, 12, 10),
EnumGenreApi.MASCULIN, EnumStatutApi.NONCADRE, 0, "1 rue du Louvre, 63000, Clermont-Ferrand", "0660258644",
"jean.dupont@gmail.com", "jean.dupont@apside-groupe.com", new DateTime(2023, 12, 17), 1);
UpdateApiDo = new CollaborateurApiDto(1, "Dupont 2", "Jean", new DateTime(1980, 12, 10),
EnumGenreApi.MASCULIN, EnumStatutApi.NONCADRE, 0, "1 rue du Louvre, 63000, Clermont-Ferrand", "0660258644",
"jean.dupont@gmail.com", "jean.dupont@apside-groupe.com", new DateTime(2023, 12, 17), 1);
}
}

@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\espacecollab.backend.api\espacecollab.backend.api.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,25 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
using Microsoft.AspNetCore.Mvc;
namespace espacecollab.backend.api.Controllers;
public class AgencesController : BaseController<AgenceApiDto>
{
private AgenceService AgenceServices { get; }
public AgencesController(AgenceService agenceServices) : base(agenceServices)
{
AgenceServices = agenceServices;
}
[HttpGet("agences/{agenceId:int:min(1)}")]
public ActionResult<IEnumerable<AgenceApiDto>> GetAgencesByBusinessUnit(uint businessUnitId)
{
IEnumerable<AgenceApiDto> agences = AgenceServices.GetAgencesByBusinessUnit(businessUnitId);
if (!agences.Any())
return NotFound();
return Ok(agences);
}
}

@ -0,0 +1,68 @@
using espacecollab.backend.appservices.dtos.Interfaces;
using espacecollab.backend.appservices.interfaces;
using Microsoft.AspNetCore.Mvc;
namespace espacecollab.backend.api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public abstract class BaseController<TO> : Controller, IBaseController<TO> where TO : class, IGenericIdApiDto
{
protected IGenericsServices<TO> Services { get; }
protected BaseController(IGenericsServices<TO> services)
{
Services = services;
}
[HttpGet]
public ActionResult<IEnumerable<TO>> GetAll()
{
return Ok(Services.GetAll());
}
[HttpGet("{id:int:min(1)}")]
public ActionResult<TO> GetById(uint id)
{
TO? apiDtos = Services.GetById(id);
if (apiDtos == null)
return NotFound();
return Ok(apiDtos);
}
[HttpPost]
public virtual ActionResult<TO> Add(TO apiDto)
{
TO? addedApiDto = Services.Add(apiDto);
if (addedApiDto == null)
return Problem();
return Ok(addedApiDto);
}
[HttpDelete("{id:int:min(1)}")]
public virtual ActionResult Delete(uint id)
{
bool isDeleted = Services.Delete(id);
if (!isDeleted)
return Problem();
return Ok();
}
[HttpPut("{id:int:min(1)}")]
public virtual ActionResult<TO> Update(uint id, TO apiDto)
{
if (apiDto.Id != id)
return Unauthorized();
TO? updatedApiDto = Services.Update(apiDto);
if (updatedApiDto == null)
return Problem();
return Ok(updatedApiDto);
}
}
}

@ -0,0 +1,16 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
using Microsoft.AspNetCore.Mvc;
namespace espacecollab.backend.api.Controllers
{
//[Route("api/[controller]")]
//[ApiController]
public class BusinessUnitsController : BaseController<BusinessUnitApiDto>
{
public BusinessUnitsController(BusinessUnitService businessUnitServices) : base(businessUnitServices)
{
}
}
}

@ -0,0 +1,94 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
using Microsoft.AspNetCore.Mvc;
namespace espacecollab.backend.api.Controllers;
public class CollaborateursController : BaseController<CollaborateurApiDto>
{
private CollaborateursService CollaborateursServices { get; }
public CollaborateursController(CollaborateursService collaborateursServices) : base(collaborateursServices)
{
CollaborateursServices = collaborateursServices;
}
[HttpPost]
public override ActionResult<CollaborateurApiDto> Add(CollaborateurApiDto apiDto)
{
(CollaborateurApiDto?,int) addedApiDto = CollaborateursServices.Add(apiDto);
if (addedApiDto.Item1 == null)
{
if(addedApiDto.Item2 == 1)
{
return Conflict("Erreur lors de la création du collaborateur : Le mail Apside renseigné est déjà utilisé pour un autre collaborateur.");
}
else if (addedApiDto.Item2 == 2)
{
return ValidationProblem("Erreur lors de la création du collaborateur : Erreur de validation de l'entité.");
}
else
return Problem("Erreur lors de la création du collaborateur : Problème interne");
}
return Ok(addedApiDto.Item1);
}
[HttpPut("{id:int:min(1)}")]
public override ActionResult<CollaborateurApiDto> Update(uint id, CollaborateurApiDto apiDto)
{
if (apiDto.Id != id)
return Unauthorized();
(CollaborateurApiDto?, int) updatedApiDto = CollaborateursServices.Update(apiDto);
if (updatedApiDto.Item1 == null)
{
if (updatedApiDto.Item2 == 1)
{
return NoContent();
}
else if (updatedApiDto.Item2 == 2)
{
return Conflict("Erreur lors de la mise à jour du collaborateur : Le mail Apside renseigné est déjà utilisé pour un autre collaborateur.");
}
else if (updatedApiDto.Item2 == 3)
{
return ValidationProblem("Erreur lors de la mise à jour du collaborateur : Erreur de validation de l'entité.");
}
else return Problem();
}
return Ok(updatedApiDto);
}
[HttpDelete("{id:int:min(1)}")]
public override ActionResult Delete(uint id)
{
bool isDeleted = CollaborateursServices.Delete(id);
if (!isDeleted)
return Problem();
return Ok();
}
[HttpGet("businessunit/{businessUnitId:int:min(1)}")]
public ActionResult<IEnumerable<CollaborateurApiDto>> GetCollaborateursByBusinessUnit(uint businessUnitId)
{
IEnumerable<CollaborateurApiDto> collaborateurs = CollaborateursServices.GetCollaborateursByBusinessUnit(businessUnitId);
if (!collaborateurs.Any())
return NotFound();
return Ok(collaborateurs);
}
[HttpGet("apsidemail/{apsideMail:minlength(1):regex(^\\S.*)}")]
public ActionResult<CollaborateurApiDto> GetCollaborateurByApsideMail(string apsideMail)
{
CollaborateurApiDto? collaborateur = CollaborateursServices.GetCollaborateurByApsideMail(apsideMail);
if (collaborateur == null)
return NotFound();
return Ok(collaborateur);
}
}

@ -0,0 +1,12 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
namespace espacecollab.backend.api.Controllers
{
public class FonctionsController : BaseController<FonctionApiDto>
{
public FonctionsController(FonctionService fonctionService) : base(fonctionService)
{
}
}
}

@ -0,0 +1,17 @@
using espacecollab.backend.appservices.dtos.Interfaces;
using Microsoft.AspNetCore.Mvc;
namespace espacecollab.backend.api.Controllers;
public interface IBaseController<TO> where TO : class, IGenericIdApiDto
{
ActionResult<IEnumerable<TO>> GetAll();
ActionResult<TO> GetById(uint id);
ActionResult<TO> Add(TO apiDto);
ActionResult Delete(uint id);
ActionResult<TO> Update(uint id, TO apiDto);
}

@ -0,0 +1,11 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
namespace espacecollab.backend.api.Controllers;
public class PeriodeEssaisController : BaseController<PeriodeEssaiApiDto>
{
public PeriodeEssaisController(PeriodeEssaiService periodeEssaiService) : base(periodeEssaiService)
{
}
}

@ -0,0 +1,13 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
using Microsoft.AspNetCore.Mvc;
namespace espacecollab.backend.api.Controllers;
public class ReferencementsController : BaseController<ReferencementApiDto>
{
public ReferencementsController(ReferencementService referencementServices) : base(referencementServices)
{
}
}

@ -0,0 +1,12 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
namespace espacecollab.backend.api.Controllers
{
public class TechnologiesController : BaseController<TechnologieApiDto>
{
public TechnologiesController(TechnologieServices technologieServices) : base(technologieServices)
{
}
}
}

@ -0,0 +1,29 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["espacecollab.backend.api/espacecollab.backend.api.csproj", "espacecollab.backend.api/"]
COPY ["espacecollab.backend.appservices/espacecollab.backend.appservices.csproj", "espacecollab.backend.appservices/"]
COPY ["espacecollab.backend.appservices.dtos/espacecollab.backend.appservices.dtos.csproj", "espacecollab.backend.appservices.dtos/"]
COPY ["espacecollab.backend.infrastructure.sql.dtos/espacecollab.backend.infrastructure.sql.dtos.csproj", "espacecollab.backend.infrastructure.sql.dtos/"]
COPY ["espacecollab.backend.appservices.interfaces/espacecollab.backend.appservices.interfaces.csproj", "espacecollab.backend.appservices.interfaces/"]
COPY ["espacecollab.backend.infrastructure.sql/espacecollab.backend.infrastructure.sql.csproj", "espacecollab.backend.infrastructure.sql/"]
COPY ["espacecollab.backend.infrastructure.interfaces/espacecollab.backend.infrastructure.interfaces.csproj", "espacecollab.backend.infrastructure.interfaces/"]
COPY ["espacecollab.backend.infrastructure.fake/espacecollab.backend.infrastructure.fake.csproj", "espacecollab.backend.infrastructure.fake/"]
RUN dotnet restore "espacecollab.backend.api/espacecollab.backend.api.csproj"
COPY . .
WORKDIR "/src/espacecollab.backend.api"
RUN dotnet build "espacecollab.backend.api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "espacecollab.backend.api.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "espacecollab.backend.api.dll"]

@ -0,0 +1,16 @@
namespace espacecollab.backend.api;
public static class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}

@ -0,0 +1,38 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:27916",
"sslPort": 44341
}
},
"profiles": {
"espacecollab.backend.api": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"dotnetRunMessages": true
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true,
"useSSL": true
}
}
}

@ -0,0 +1,42 @@
using espacecollab.backend.appservices;
using espacecollab.backend.infrastructure.fake;
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql;
using espacecollab.backend.infrastructure.sql.Options;
using espacecollab.backend.infrastructure.sql.Repository;
namespace espacecollab.backend.api;
internal static class Register
{
public static void InjectDependencies(IServiceCollection services, SqlOption contextOptions)
{
services.AddCors();
services.AddScoped<CollaborateursService>();
services.AddScoped<AgenceService>();
services.AddScoped<BusinessUnitService>();
services.AddScoped<FonctionService>();
services.AddScoped<PeriodeEssaiService>();
services.AddScoped<ReferencementService>();
if (contextOptions.LoadFake)
{
services.AddSingleton<ICollaborateurRepository, FakeCollaborateurRepository>();
//services.AddSingleton<IAgenceRepository, FakeAgenceRepository>();
//services.AddSingleton<IBusinessUnitRepository, FakeBusinessUnitRepository>();
services.AddSingleton<IFonctionRepository, FakeFonctionRepository>();
services.AddSingleton<IPeriodeEssaiRepository, FakePeriodeEssaiRepository>();
}
else
{
services.AddScoped<MainDbContext>();
services.AddScoped<ICollaborateurRepository, CollaborateurSqlRepository>();
services.AddScoped<IAgenceRepository, AgenceSqlRepository>();
services.AddScoped<IBusinessUnitRepository, BusinessUnitSqlRepository>();
services.AddScoped<IFonctionRepository, FonctionSqlRepository>();
services.AddScoped<ITechnologieRepository, TechnologieSqlRepository>();
services.AddScoped<IPeriodeEssaiRepository, PeriodeEssaiSqlRepository>();
services.AddScoped<IReferencementRepository, ReferencementSqlRepository>();
}
}
}

@ -0,0 +1,57 @@
using espacecollab.backend.infrastructure.sql.Options;
using System.Text.Json.Serialization;
namespace espacecollab.backend.api;
public class Startup
{
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
IConfigurationSection sqlSection = Configuration.GetSection(SqlOption.Key);
services.Configure<SqlOption>(sqlSection);
SqlOption sqlOptions = sqlSection.Get<SqlOption>();
services.AddControllers().AddJsonOptions(opt =>
{
opt.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
}); ;
services.AddRouting(options => options.LowercaseUrls = true);
services.AddEndpointsApiExplorer();
services.AddSwaggerGen();
Register.InjectDependencies(services, sqlOptions);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseCors(
options => options.WithOrigins("http://localhost:4200", "http://localhost:8082", "http://localhost:8083", "http://localhost:5000", "http://localhost:5001").AllowAnyMethod().AllowAnyHeader()
);
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}

@ -0,0 +1,14 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Sql": {
"LoadFake": false,
"ConnectionString": "server=database;user=root;password=root;database=collaborateur_epa" //préprod
//"ConnectionString": "server=localhost;user=root;password=root;database=collaborateur_epa" //local
}
}

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>5a7cf5e2-2bf7-4dae-aea9-2522da3cf955</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.16.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\espacecollab.backend.appservices\espacecollab.backend.appservices.csproj" />
<ProjectReference Include="..\espacecollab.backend.infrastructure.fake\espacecollab.backend.infrastructure.fake.csproj" />
<ProjectReference Include="..\espacecollab.backend.infrastructure.sql\espacecollab.backend.infrastructure.sql.csproj" />
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project>

@ -0,0 +1,8 @@
using espacecollab.backend.appservices.dtos.Interfaces;
namespace espacecollab.backend.appservices.dtos;
public record AgenceApiDto(uint Id, string Name, uint BusinessUnitId) : IGenericIdApiDto
{
public uint Id { get; set; } = Id;
}

@ -0,0 +1,8 @@
using espacecollab.backend.appservices.dtos.Interfaces;
namespace espacecollab.backend.appservices.dtos;
public record BusinessUnitApiDto(uint Id, string Name) : IGenericIdApiDto
{
public uint Id { get; set; } = Id;
}

@ -0,0 +1,10 @@
using espacecollab.backend.appservices.dtos.Interfaces;
using espacecollab.backend.appservices.dtos.Values;
namespace espacecollab.backend.appservices.dtos;
public record CollaborateurApiDto(uint Id, string Name, string FirstName, DateTime BirthDate, EnumGenreApi Gender, EnumStatutApi Status, uint ChildrenNumber, string Address,
string Telephone, string PersonalMail, string ApsideMail, DateTime? ResignationDate, uint BusinessUnitId) : IGenericIdApiDto
{
public uint Id { get; set; } = Id;
}

@ -0,0 +1,8 @@
using espacecollab.backend.appservices.dtos.Interfaces;
namespace espacecollab.backend.appservices.dtos;
public record FonctionApiDto(uint Id, string Intitule) : IGenericIdApiDto
{
public uint Id { get; set; } = Id;
}

@ -0,0 +1,6 @@
namespace espacecollab.backend.appservices.dtos.Interfaces;
public interface IGenericIdApiDto
{
public uint Id { get; set; }
}

@ -0,0 +1,15 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices.dtos.Mappers;
public static class AgenceMapper
{
public static AgenceApiDto ToApi(this AgenceSqlDto agenceSqlDto)
{
return new AgenceApiDto((uint)agenceSqlDto.Id, agenceSqlDto.Name,(uint)agenceSqlDto.BusinessUnitId);
}
public static AgenceSqlDto ToSql(this AgenceApiDto agenceApiDto)
{
return new AgenceSqlDto((int)agenceApiDto.Id, agenceApiDto.Name, (int)agenceApiDto.BusinessUnitId);
}
}

@ -0,0 +1,15 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices.dtos.Mappers;
public static class BusinessUnitMapper
{
public static BusinessUnitApiDto ToApi(this BusinessUnitSqlDto businessUnitSqlDto)
{
return new BusinessUnitApiDto((uint)businessUnitSqlDto.Id, businessUnitSqlDto.Name);
}
public static BusinessUnitSqlDto ToSql(this BusinessUnitApiDto businessUnitApiDto)
{
return new BusinessUnitSqlDto((int)businessUnitApiDto.Id, businessUnitApiDto.Name);
}
}

@ -0,0 +1,22 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices.dtos.Mappers;
public static class CollaborateurMapper
{
public static CollaborateurApiDto ToApi(this CollaborateurSqlDto collaborateurSql)
{
return new CollaborateurApiDto((uint)collaborateurSql.Id, collaborateurSql.Name, collaborateurSql.FirstName,
collaborateurSql.BirthDate, collaborateurSql.Gender.ToEnumGenreApi(), collaborateurSql.Status.ToEnumStatutApi(), (uint)collaborateurSql.ChildrenNumber,
collaborateurSql.Address, collaborateurSql.Telephone, collaborateurSql.PersonalMail, collaborateurSql.ApsideMail,
collaborateurSql.ResignationDate, (uint)collaborateurSql.BusinessUnitId);
}
public static CollaborateurSqlDto ToSql(this CollaborateurApiDto collaborateurApi)
{
return new CollaborateurSqlDto((int)collaborateurApi.Id, collaborateurApi.Name, collaborateurApi.FirstName,
collaborateurApi.BirthDate, collaborateurApi.Gender.ToEnumGenreSql(), collaborateurApi.Status.ToEnumStatutSql(), (int)collaborateurApi.ChildrenNumber,
collaborateurApi.Address, collaborateurApi.Telephone, collaborateurApi.PersonalMail, collaborateurApi.ApsideMail,
collaborateurApi.ResignationDate, (int)collaborateurApi.BusinessUnitId);
}
}

@ -0,0 +1,29 @@
using espacecollab.backend.appservices.dtos.Values;
using espacecollab.backend.infrastructure.sql.dtos.Values;
namespace espacecollab.backend.appservices.dtos.Mappers;
public static class EnumGenreMapper
{
public static EnumGenreApi ToEnumGenreApi(this EnumGenreSql enumGenreSql)
{
return enumGenreSql switch
{
EnumGenreSql.MASCULIN => EnumGenreApi.MASCULIN,
EnumGenreSql.FEMININ => EnumGenreApi.FEMININ,
EnumGenreSql.AUTRE => EnumGenreApi.AUTRE,
_ => EnumGenreApi.AUTRE,
};
}
public static EnumGenreSql ToEnumGenreSql(this EnumGenreApi enumGenreApi)
{
return enumGenreApi switch
{
EnumGenreApi.MASCULIN => EnumGenreSql.MASCULIN,
EnumGenreApi.FEMININ => EnumGenreSql.FEMININ,
EnumGenreApi.AUTRE => EnumGenreSql.AUTRE,
_ => EnumGenreSql.AUTRE,
};
}
}

@ -0,0 +1,31 @@
using espacecollab.backend.appservices.dtos.Values;
using espacecollab.backend.infrastructure.sql.dtos.Values;
namespace espacecollab.backend.appservices.dtos.Mappers;
public static class EnumStatutMapper
{
public static EnumStatutApi ToEnumStatutApi(this EnumStatutSql enumStatutSql)
{
return enumStatutSql switch
{
EnumStatutSql.STAGIAIRE => EnumStatutApi.STAGIAIRE,
EnumStatutSql.NONCADRE => EnumStatutApi.NONCADRE,
EnumStatutSql.CADRE => EnumStatutApi.CADRE,
EnumStatutSql.ALTERNANT => EnumStatutApi.ALTERNANT,
_ => EnumStatutApi.NONCADRE,
};
}
public static EnumStatutSql ToEnumStatutSql(this EnumStatutApi enumStatutApi)
{
return enumStatutApi switch
{
EnumStatutApi.STAGIAIRE => EnumStatutSql.STAGIAIRE,
EnumStatutApi.NONCADRE => EnumStatutSql.NONCADRE,
EnumStatutApi.CADRE => EnumStatutSql.CADRE,
EnumStatutApi.ALTERNANT => EnumStatutSql.ALTERNANT,
_ => EnumStatutSql.NONCADRE,
};
}
}

@ -0,0 +1,15 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices.dtos.Mappers;
public static class FonctionMapper
{
public static FonctionApiDto ToApi(this FonctionSqlDto fonctionSqlDto)
{
return new FonctionApiDto((uint)fonctionSqlDto.Id, fonctionSqlDto.Intitule);
}
public static FonctionSqlDto ToSql(this FonctionApiDto fonctionApiDto)
{
return new FonctionSqlDto((int)fonctionApiDto.Id, fonctionApiDto.Intitule);
}
}

@ -0,0 +1,22 @@
using espacecollab.backend.appservices.dtos.Values;
using espacecollab.backend.infrastructure.sql.dtos;
using espacecollab.backend.infrastructure.sql.dtos.Values;
namespace espacecollab.backend.appservices.dtos.Mappers;
public static class PeriodeEssaiMapper
{
public static PeriodeEssaiApiDto ToApi(this PeriodeEssaiSqlDto periodeEssaiSqlDto)
{
return new PeriodeEssaiApiDto((uint)periodeEssaiSqlDto.Id, periodeEssaiSqlDto.StartingDate,
periodeEssaiSqlDto.PlannedEndingDate, periodeEssaiSqlDto.RealEndingDate, periodeEssaiSqlDto.Comment,
(EnumIssueApi?)periodeEssaiSqlDto.Issue, (uint)periodeEssaiSqlDto.CollaborateurId);
}
public static PeriodeEssaiSqlDto ToSql(this PeriodeEssaiApiDto periodeEssaiApiDto)
{
return new PeriodeEssaiSqlDto((int)periodeEssaiApiDto.Id, periodeEssaiApiDto.StartingDate,
periodeEssaiApiDto.PlannedEndingDate, periodeEssaiApiDto.RealEndingDate, periodeEssaiApiDto.Comment,
(EnumIssueSql?)periodeEssaiApiDto.Issue, (int)periodeEssaiApiDto.CollaborateurId);
}
}

@ -0,0 +1,15 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices.dtos.Mappers;
public static class ReferencementMapper
{
public static ReferencementApiDto ToApi(this ReferencementSqlDto referencementSqlDto)
{
return new ReferencementApiDto((uint)referencementSqlDto.Id, referencementSqlDto.StartingDate,referencementSqlDto.EndingDate,(uint)referencementSqlDto.ReferredId, (uint)referencementSqlDto.ReferrerId);
}
public static ReferencementSqlDto ToSql(this ReferencementApiDto referencementApiDto)
{
return new ReferencementSqlDto((int)referencementApiDto.Id, referencementApiDto.StartingDate, referencementApiDto.EndingDate, (int)referencementApiDto.ReferredId, (int)referencementApiDto.ReferrerId);
}
}

@ -0,0 +1,15 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices.dtos.Mappers;
public static class TechnologieMapper
{
public static TechnologieApiDto ToApi(this TechnologieSqlDto technologieSqlDto)
{
return new TechnologieApiDto((uint)technologieSqlDto.Id, technologieSqlDto.Name);
}
public static TechnologieSqlDto ToSql(this TechnologieApiDto technologieApiDto)
{
return new TechnologieSqlDto((int)technologieApiDto.Id, technologieApiDto.Name);
}
}

@ -0,0 +1,9 @@
using espacecollab.backend.appservices.dtos.Interfaces;
using espacecollab.backend.appservices.dtos.Values;
namespace espacecollab.backend.appservices.dtos;
public record PeriodeEssaiApiDto(uint Id, DateTime StartingDate, DateTime PlannedEndingDate, DateTime? RealEndingDate, string? Comment, EnumIssueApi? Issue, uint CollaborateurId) : IGenericIdApiDto
{
public uint Id { get; set; } = Id;
}

@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.appservices.dtos.Interfaces;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.appservices.dtos;
public record ReferencementApiDto(uint Id, DateTime StartingDate, DateTime? EndingDate, uint ReferredId, uint ReferrerId) : IGenericIdApiDto
{
public uint Id { get; set; } = Id;
}

@ -0,0 +1,8 @@
using espacecollab.backend.appservices.dtos.Interfaces;
namespace espacecollab.backend.appservices.dtos;
public record TechnologieApiDto(uint Id, string Name) : IGenericIdApiDto
{
public uint Id { get; set; } = Id;
}

@ -0,0 +1,8 @@
namespace espacecollab.backend.appservices.dtos.Values;
public enum EnumGenreApi
{
MASCULIN,
FEMININ,
AUTRE
}

@ -0,0 +1,11 @@
namespace espacecollab.backend.appservices.dtos.Values;
public enum EnumIssueApi
{
VALIDEE,
PROLONGEE_COLLAB,
PROLONGEE_APSIDE,
ARRETEE_COLLAB,
ARRETEE_APSIDE,
INDETERMINEE
}

@ -0,0 +1,9 @@
namespace espacecollab.backend.appservices.dtos.Values;
public enum EnumStatutApi
{
CADRE,
NONCADRE,
ALTERNANT,
STAGIAIRE
}

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\espacecollab.backend.infrastructure.sql.dtos\espacecollab.backend.infrastructure.sql.dtos.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,16 @@
using espacecollab.backend.appservices.dtos.Interfaces;
namespace espacecollab.backend.appservices.interfaces;
public interface IGenericsServices<T> where T : class, IGenericIdApiDto
{
T? Add(T apiDto);
IEnumerable<T> GetAll();
T? GetById(uint id);
T? Update(T apiDto);
bool Delete(uint apiDtoId);
}

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\espacecollab.backend.appservices.dtos\espacecollab.backend.appservices.dtos.csproj" />
<ProjectReference Include="..\espacecollab.backend.infrastructure.sql.dtos\espacecollab.backend.infrastructure.sql.dtos.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,22 @@
using espacecollab.backend.appservices.dtos;
using espacecollab.backend.appservices.dtos.Mappers;
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices;
public class AgenceService : GenericsServices<AgenceSqlDto, AgenceApiDto>
{
private IAgenceRepository AgenceRepository { get; }
public AgenceService(IAgenceRepository agenceRepository)
: base(agenceRepository, AgenceMapper.ToApi, AgenceMapper.ToSql)
{
AgenceRepository = agenceRepository;
}
public IEnumerable<AgenceApiDto> GetAgencesByBusinessUnit(uint businessUnitId)
{
return AgenceRepository.GetAgencesByBusinessUnit((int)businessUnitId).Select(bu => bu.ToApi());
}
}

@ -0,0 +1,15 @@
using espacecollab.backend.appservices.dtos;
using espacecollab.backend.appservices.dtos.Mappers;
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices;
public class BusinessUnitService : GenericsServices<BusinessUnitSqlDto, BusinessUnitApiDto>
{
public BusinessUnitService(IBusinessUnitRepository businessUnitRepository)
:base(businessUnitRepository, BusinessUnitMapper.ToApi, BusinessUnitMapper.ToSql)
{}
}

@ -0,0 +1,100 @@
using espacecollab.backend.appservices.dtos;
using espacecollab.backend.appservices.dtos.Mappers;
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices;
public class CollaborateursService : GenericsServices<CollaborateurSqlDto, CollaborateurApiDto>
{
private ICollaborateurRepository CollaborateurRepository { get; }
private IPeriodeEssaiRepository PeriodeEssaiRepository { get; }
private IReferencementRepository ReferencementRepository { get; }
public CollaborateursService(ICollaborateurRepository collaborateurRepository, IPeriodeEssaiRepository periodeEssaiRepository, IReferencementRepository referencementRepository)
: base(collaborateurRepository, CollaborateurMapper.ToApi, CollaborateurMapper.ToSql)
{
CollaborateurRepository = collaborateurRepository;
PeriodeEssaiRepository = periodeEssaiRepository;
ReferencementRepository = referencementRepository;
}
public (CollaborateurApiDto?,int) Add(CollaborateurApiDto apiDto)
{
if(GetAll().Where(collab => apiDto.ApsideMail == collab.ApsideMail).Any())
{
return (null,1);
}
CollaborateurSqlDto sqlDto = apiDto.ToSql();
CollaborateurSqlDto? entitySqlValidation = CollaborateurRepository.Add(sqlDto);
if (entitySqlValidation == null)
return (null,2);
return (entitySqlValidation.ToApi(),0);
}
public (CollaborateurApiDto?,int) Update(CollaborateurApiDto apiDto)
{
if (GetById(apiDto.Id) == null)
return (null,1);
if (GetAll().Where(collab => apiDto.ApsideMail == collab.ApsideMail && apiDto.Id != collab.Id).Any())
{
return (null,2);
}
CollaborateurSqlDto sqlDto = apiDto.ToSql();
CollaborateurSqlDto? sqlDtoValidation = CollaborateurRepository.Update(sqlDto);
if (sqlDtoValidation == null)
return (null,3);
return (sqlDtoValidation.ToApi(),0);
}
public new bool Delete(uint apiDtoId)
{
IEnumerable<ReferencementSqlDto>? referencements = ReferencementRepository.GetAll();
IEnumerable<PeriodeEssaiSqlDto>? periodeEssais = PeriodeEssaiRepository.GetAll();
if (referencements.Any())
{
foreach (var referencement in referencements)
{
if (referencement.ReferredId == apiDtoId || referencement.ReferrerId == apiDtoId)
{
ReferencementRepository.Delete(referencement.Id);
}
}
}
if (periodeEssais.Any())
{
foreach (var periodeEssai in periodeEssais)
{
if (periodeEssai.CollaborateurId== apiDtoId)
{
PeriodeEssaiRepository.Delete(periodeEssai.Id);
}
}
}
return CollaborateurRepository.Delete((int)apiDtoId);
}
public IEnumerable<CollaborateurApiDto> GetCollaborateursByBusinessUnit(uint businessUnitId)
{
return CollaborateurRepository.GetCollaborateursByBusinessUnit((int)businessUnitId).Select(collaborateurSql => collaborateurSql.ToApi());
}
public CollaborateurApiDto? GetCollaborateurByApsideMail(string apsideMail)
{
if (string.IsNullOrEmpty(apsideMail))
return null;
return CollaborateurRepository.GetCollaborateurByApsideMail(apsideMail)?.ToApi();
}
}

@ -0,0 +1,14 @@
using espacecollab.backend.appservices.dtos;
using espacecollab.backend.appservices.dtos.Mappers;
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices;
public class FonctionService : GenericsServices<FonctionSqlDto, FonctionApiDto>
{
public FonctionService(IFonctionRepository fonctionRepository)
:base(fonctionRepository, FonctionMapper.ToApi, FonctionMapper.ToSql)
{
}
}

@ -0,0 +1,66 @@
using espacecollab.backend.appservices.dtos.Interfaces;
using espacecollab.backend.appservices.interfaces;
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.appservices;
public abstract class GenericsServices<T, TO> : IGenericsServices<TO> where T : class, IGenericIdSqlDto
where TO : class, IGenericIdApiDto
{
private Func<T, TO> MapperToApiDto { get; }
private Func<TO, T> MapperToSqlDto { get; }
private IGenericRepository<T> GenericRepository { get; }
protected GenericsServices(IGenericRepository<T> genericRepository, Func<T, TO> mapperToApiDto, Func<TO, T> mapperToSqlDto)
{
GenericRepository = genericRepository;
MapperToApiDto = mapperToApiDto;
MapperToSqlDto = mapperToSqlDto;
}
public IEnumerable<TO> GetAll()
{
return GenericRepository.GetAll().Select(entity => MapperToApiDto(entity)).ToList();
}
public TO? GetById(uint id)
{
T? entity = GenericRepository.GetById((int)id);
if (entity == null)
return null;
return MapperToApiDto(entity);
}
public virtual TO? Add(TO apiDto)
{
T sqlDto = MapperToSqlDto(apiDto);
T? entitySqlValidation = GenericRepository.Add(sqlDto);
if (entitySqlValidation == null)
return null;
return MapperToApiDto(entitySqlValidation);
}
public virtual TO? Update(TO apiDto)
{
if (GetById(apiDto.Id) == null)
return null;
T sqlDto = MapperToSqlDto(apiDto);
T? sqlDtoValidation = GenericRepository.Update(sqlDto);
if (sqlDtoValidation == null)
return null;
return MapperToApiDto(sqlDtoValidation);
}
public bool Delete(uint apiDtoId)
{
return GenericRepository.Delete((int)apiDtoId);
}
}

@ -0,0 +1,14 @@
using espacecollab.backend.appservices.dtos;
using espacecollab.backend.appservices.dtos.Mappers;
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices;
public class PeriodeEssaiService : GenericsServices<PeriodeEssaiSqlDto, PeriodeEssaiApiDto>
{
public PeriodeEssaiService(IPeriodeEssaiRepository agenceRepository)
: base(agenceRepository, PeriodeEssaiMapper.ToApi, PeriodeEssaiMapper.ToSql)
{
}
}

@ -0,0 +1,18 @@
using espacecollab.backend.appservices.dtos;
using espacecollab.backend.appservices.dtos.Mappers;
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices;
public class ReferencementService : GenericsServices<ReferencementSqlDto, ReferencementApiDto>
{
private IReferencementRepository ReferencementRepository { get; }
public ReferencementService(IReferencementRepository referencementRepository)
: base(referencementRepository, ReferencementMapper.ToApi, ReferencementMapper.ToSql)
{
ReferencementRepository = referencementRepository;
}
}

@ -0,0 +1,14 @@
using espacecollab.backend.appservices.dtos;
using espacecollab.backend.appservices.dtos.Mappers;
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices;
public class TechnologieServices : GenericsServices<TechnologieSqlDto, TechnologieApiDto>
{
public TechnologieServices(ITechnologieRepository technologieRepository)
:base(technologieRepository, TechnologieMapper.ToApi, TechnologieMapper.ToSql)
{
}
}

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\espacecollab.backend.appservices.dtos\espacecollab.backend.appservices.dtos.csproj" />
<ProjectReference Include="..\espacecollab.backend.appservices.interfaces\espacecollab.backend.appservices.interfaces.csproj" />
<ProjectReference Include="..\espacecollab.backend.infrastructure.sql\espacecollab.backend.infrastructure.sql.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,16 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.fake;
//public class FakeAgenceRepository : GenericFakeRepository<AgenceSqlDto>, IAgenceRepository
//{
// public FakeAgenceRepository()
// {
// Context = new List<AgenceSqlDto>
// {
// new(1, "Tours"),
// new(2, "Clermont-Ferrand")
// };
// }
//}

@ -0,0 +1,21 @@
//using espacecollab.backend.infrastructure.interfaces;
//using espacecollab.backend.infrastructure.sql.dtos;
//namespace espacecollab.backend.infrastructure.fake;
//public class FakeBusinessUnitRepository : GenericFakeRepository<BusinessUnitSqlDto>, IBusinessUnitRepository
//{
// public FakeBusinessUnitRepository()
// {
// Context = new List<BusinessUnitSqlDto>
// {
// new(1, "BU 1", 1),
// new(2, "BU 2", 1)
// };
// }
// public IList<BusinessUnitSqlDto> GetBusinessUnitsByAgence(int agenceId)
// {
// return Context.Where(c => c.AgenceId == agenceId).ToList();
// }
//}

@ -0,0 +1,35 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
using espacecollab.backend.infrastructure.sql.dtos.Values;
namespace espacecollab.backend.infrastructure.fake;
public class FakeCollaborateurRepository : GenericFakeRepository<CollaborateurSqlDto>, ICollaborateurRepository
{
public FakeCollaborateurRepository()
{
Context = new List<CollaborateurSqlDto>
{
new(1, "Dupont", "Jean", new DateTime(1980, 12, 10),
EnumGenreSql.MASCULIN, EnumStatutSql.NONCADRE, 0, "1 rue du Louvre, 63000, Clermont-Ferrand", "0660258644",
"jean.dupont@gmail.com", "jean.dupont@apside-groupe.com", new DateTime(2023, 12, 17), 1),
new(2, "Michel", "Laura", new DateTime(1985, 08, 12),
EnumGenreSql.FEMININ, EnumStatutSql.NONCADRE, 0, "5 rue du Louvre, 63000, Clermont-Ferrand", "0660258644",
"laura.michel@gmail.com", "laura.michel@apside-groupe.com", new DateTime(2023, 12, 17), 1)
};
}
#region méthodes spécifiques à l'interface ICollaborateurRepository
public IList<CollaborateurSqlDto> GetCollaborateursByBusinessUnit(int businessUnitId)
{
return Context.Where(entity => entity.BusinessUnitId == businessUnitId).ToList();
}
public CollaborateurSqlDto GetCollaborateurByApsideMail(string apsideMail)
{
return Context.First(entity => entity.ApsideMail == apsideMail);
}
#endregion
}

@ -0,0 +1,16 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.fake;
public class FakeFonctionRepository : GenericFakeRepository<FonctionSqlDto>, IFonctionRepository
{
public FakeFonctionRepository()
{
Context = new List<FonctionSqlDto>
{
new(1, "Fonction 1"),
new(2, "Fonction 2")
};
}
}

@ -0,0 +1,17 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
using espacecollab.backend.infrastructure.sql.dtos.Values;
namespace espacecollab.backend.infrastructure.fake;
public class FakePeriodeEssaiRepository : GenericFakeRepository<PeriodeEssaiSqlDto>, IPeriodeEssaiRepository
{
public FakePeriodeEssaiRepository()
{
Context = new List<PeriodeEssaiSqlDto>
{
new(1, new DateTime(2021, 10, 1), new DateTime(2021, 12, 1), new DateTime(2022, 1, 1), "A voir", EnumIssueSql.VALIDEE, 1),
new(2, new DateTime(2021, 10, 1), new DateTime(2021, 12, 1), new DateTime(2022, 1, 1), "Ne pas donner suite", EnumIssueSql.ARRETEE_APSIDE, 2)
};
}
}

@ -0,0 +1,48 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.fake;
public class GenericFakeRepository<T> : IGenericRepository<T> where T : class, IGenericIdSqlDto
{
protected List<T> Context { get; set; } = new();
public virtual T? Add(T entity)
{
int lastId = Context.Max(e => e.Id);
entity.Id = lastId + 1;
Context.Add(entity);
return entity;
}
public virtual bool Delete(int entityId)
{
T? entity = GetById(entityId);
if (entity == null) return false;
return Context.Remove(entity);
}
public virtual IEnumerable<T> GetAll()
{
return Context.ToList();
}
public virtual T? GetById(int id)
{
return Context.FirstOrDefault(entity => entity.Id == id);
}
public virtual T? Update(T entity)
{
T? oldEntity = GetById(entity.Id);
if (oldEntity == null)
return null;
Context.Remove(oldEntity);
Context.Add(entity);
return Context.FirstOrDefault(e => e.Id == entity.Id);
}
}

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\espacecollab.backend.infrastructure.interfaces\espacecollab.backend.infrastructure.interfaces.csproj" />
<ProjectReference Include="..\espacecollab.backend.infrastructure.sql.dtos\espacecollab.backend.infrastructure.sql.dtos.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,8 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.interfaces;
public interface IAgenceRepository : IGenericRepository<AgenceSqlDto>
{
public IList<AgenceSqlDto> GetAgencesByBusinessUnit(int businessUnitId);
}

@ -0,0 +1,7 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.interfaces;
public interface IBusinessUnitRepository : IGenericRepository<BusinessUnitSqlDto>
{
}

@ -0,0 +1,9 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.interfaces;
public interface ICollaborateurRepository : IGenericRepository<CollaborateurSqlDto>
{
CollaborateurSqlDto? GetCollaborateurByApsideMail(string apsideMail);
IList<CollaborateurSqlDto> GetCollaborateursByBusinessUnit(int businessUnitId);
}

@ -0,0 +1,8 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.interfaces;
public interface IFonctionRepository : IGenericRepository<FonctionSqlDto>
{
}

@ -0,0 +1,12 @@
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.interfaces;
public interface IGenericRepository<T> where T : class, IGenericIdSqlDto
{
T? Add(T entity);
bool Delete(int entityId);
IEnumerable<T> GetAll();
T? GetById(int id);
T? Update(T entity);
}

@ -0,0 +1,7 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.interfaces;
public interface IPeriodeEssaiRepository : IGenericRepository<PeriodeEssaiSqlDto>
{
}

@ -0,0 +1,8 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.interfaces;
public interface IProjetRepository : IGenericRepository<ProjetSqlDto>
{
IList<ProjetSqlDto> GetProjetsByClient(string client);
}

@ -0,0 +1,7 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.interfaces;
public interface IReferencementRepository : IGenericRepository<ReferencementSqlDto>
{
}

@ -0,0 +1,8 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.interfaces
{
public interface ITechnologieRepository : IGenericRepository<TechnologieSqlDto>
{
}
}

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\espacecollab.backend.infrastructure.sql.dtos\espacecollab.backend.infrastructure.sql.dtos.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,28 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos;
[Table("agence")]
public class AgenceSqlDto : IGenericIdSqlDto
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public int BusinessUnitId { get; set; }
[ExcludeFromCodeCoverage]
private AgenceSqlDto()
{
}
public AgenceSqlDto(int id, string name, int businessUnitId)
{
Id = id;
Name = name;
BusinessUnitId = businessUnitId;
}
}

@ -0,0 +1,26 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos;
[Table("businessunit")]
public class BusinessUnitSqlDto : IGenericIdSqlDto
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
[ExcludeFromCodeCoverage]
private BusinessUnitSqlDto()
{
}
public BusinessUnitSqlDto(int id, string name)
{
Id = id;
Name = name;
}
}

@ -0,0 +1,21 @@
using System.Diagnostics.CodeAnalysis;
namespace espacecollab.backend.infrastructure.sql.dtos;
public class CollaborateurAppartientBusinessUnitSqlDto
{
public int CollaborateurId { get; set; }
public int BusinessUnitId { get; set; }
[ExcludeFromCodeCoverage]
private CollaborateurAppartientBusinessUnitSqlDto()
{
}
public CollaborateurAppartientBusinessUnitSqlDto(int collaborateurId, int businessUnitId)
{
CollaborateurId = collaborateurId;
BusinessUnitId = businessUnitId;
}
}

@ -0,0 +1,22 @@
using System.Diagnostics.CodeAnalysis;
namespace espacecollab.backend.infrastructure.sql.dtos;
public class CollaborateurCollaboreProjetSqlDto
{
public int CollaborateurId { get; set; }
public int ProjetId { get; set; }
public bool IsManager { get; set; }
[ExcludeFromCodeCoverage]
private CollaborateurCollaboreProjetSqlDto()
{
}
public CollaborateurCollaboreProjetSqlDto(int collaborateurId, int projetId, bool isManager)
{
CollaborateurId = collaborateurId;
ProjetId = projetId;
IsManager = isManager;
}
}

@ -0,0 +1,20 @@
using System.Diagnostics.CodeAnalysis;
namespace espacecollab.backend.infrastructure.sql.dtos;
public class CollaborateurEstFonctionSqlDto
{
public int CollaborateurId { get; set; }
public int FonctionId { get; set; }
[ExcludeFromCodeCoverage]
private CollaborateurEstFonctionSqlDto()
{
}
public CollaborateurEstFonctionSqlDto(int collaborateurId, int fonctionId)
{
CollaborateurId = collaborateurId;
FonctionId = fonctionId;
}
}

@ -0,0 +1,54 @@
using espacecollab.backend.infrastructure.sql.dtos.Values;
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace espacecollab.backend.infrastructure.sql.dtos;
[Table("collaborateur")]
public class CollaborateurSqlDto : IGenericIdSqlDto
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string FirstName { get; set; }
public DateTime BirthDate { get; set; }
public EnumGenreSql Gender { get; set; }
public EnumStatutSql Status { get; set; }
public int ChildrenNumber { get; set; }
public string Address { get; set; }
public string Telephone { get; set; }
public string PersonalMail { get; set; }
public string ApsideMail { get; set; }
public DateTime? ResignationDate { get; set; }
public int BusinessUnitId { get; set; }
[ExcludeFromCodeCoverage]
private CollaborateurSqlDto()
{
Name = string.Empty;
FirstName = string.Empty;
Address = string.Empty;
Telephone = string.Empty;
PersonalMail = string.Empty;
ApsideMail = string.Empty;
}
public CollaborateurSqlDto(int id, string name, string firstName, DateTime birthDate, EnumGenreSql gender, EnumStatutSql status, int childrenNumber, string address, string telephone, string personalMail, string apsideMail, DateTime? resignationDate, int businessUnitId)
{
Id = id;
Name = name;
FirstName = firstName;
BirthDate = birthDate;
Gender = gender;
Status = status;
ChildrenNumber = childrenNumber;
Address = address;
Telephone = telephone;
PersonalMail = personalMail;
ApsideMail = apsideMail;
ResignationDate = resignationDate;
BusinessUnitId = businessUnitId;
}
}

@ -0,0 +1,28 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos
{
[Table("fonction")]
public class FonctionSqlDto : IGenericIdSqlDto
{
[Key]
public int Id { get; set; }
public string Intitule { get; set; }
[ExcludeFromCodeCoverage]
private FonctionSqlDto()
{
}
public FonctionSqlDto(int id, string intitule)
{
Id = id;
Intitule = intitule;
}
}
}

@ -0,0 +1,6 @@
namespace espacecollab.backend.infrastructure.sql.dtos.Interfaces;
public interface IGenericIdSqlDto
{
public int Id { get; set; }
}

@ -0,0 +1,37 @@
using espacecollab.backend.infrastructure.sql.dtos.Values;
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace espacecollab.backend.infrastructure.sql.dtos;
[Table("periodeessai")]
public class PeriodeEssaiSqlDto : IGenericIdSqlDto
{
[Key]
public int Id { get; set; }
public DateTime StartingDate { get; set; }
public DateTime PlannedEndingDate { get; set; }
public DateTime? RealEndingDate { get; set; }
public string? Comment { get; set; }
public EnumIssueSql? Issue { get; set; }
public int CollaborateurId { get; set; }
[ExcludeFromCodeCoverage]
private PeriodeEssaiSqlDto()
{
Comment = string.Empty;
}
public PeriodeEssaiSqlDto(int id, DateTime startingDate, DateTime plannedEndingDate, DateTime? realEndingDate, string? comment, EnumIssueSql? issue, int collaborateurId)
{
Id = id;
StartingDate = startingDate;
PlannedEndingDate = plannedEndingDate;
RealEndingDate = realEndingDate;
Comment = comment;
Issue = issue;
CollaborateurId = collaborateurId;
}
}

@ -0,0 +1,33 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos;
[Table("projet")]
public class ProjetSqlDto : IGenericIdSqlDto
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string Client { get; set; }
public string Description { get; set; }
public DateTime StartingDate { get; set; }
public DateTime EndingDate { get; set; }
[ExcludeFromCodeCoverage]
private ProjetSqlDto()
{
}
public ProjetSqlDto(int id, string name, string client, string description, DateTime startingDate, DateTime endingDate)
{
Id = id;
Name = name;
Client = client;
Description = description;
StartingDate = startingDate;
EndingDate = endingDate;
}
}

@ -0,0 +1,20 @@
using System.Diagnostics.CodeAnalysis;
namespace espacecollab.backend.infrastructure.sql.dtos;
public class ProjetUtiliseTechnologieSqlDto
{
public int ProjetId { get; set; }
public int TechnologieId { get; set; }
[ExcludeFromCodeCoverage]
private ProjetUtiliseTechnologieSqlDto()
{
}
public ProjetUtiliseTechnologieSqlDto(int projetId, int technologieId)
{
ProjetId = projetId;
TechnologieId = technologieId;
}
}

@ -0,0 +1,31 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos;
[Table("referencement")]
public class ReferencementSqlDto : IGenericIdSqlDto
{
[Key]
public int Id { get; set; }
public DateTime StartingDate { get; set; }
public DateTime? EndingDate { get; set; }
public int ReferredId { get; set; }
public int ReferrerId { get; set; }
[ExcludeFromCodeCoverage]
private ReferencementSqlDto()
{
}
public ReferencementSqlDto(int id, DateTime startingDate, DateTime? endingDate, int referredId, int referrerId)
{
Id = id;
StartingDate = startingDate;
EndingDate = endingDate;
ReferredId = referredId;
ReferrerId = referrerId;
}
}

@ -0,0 +1,20 @@
using System.Diagnostics.CodeAnalysis;
namespace espacecollab.backend.infrastructure.sql.dtos;
public class SiteDeveloppeProjetSqlDto
{
public int SiteId { get; set; }
public int ProjetId { get; set; }
[ExcludeFromCodeCoverage]
private SiteDeveloppeProjetSqlDto()
{
}
public SiteDeveloppeProjetSqlDto(int siteId, int projetId)
{
SiteId = siteId;
ProjetId = projetId;
}
}

@ -0,0 +1,29 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos;
[Table("site")]
public class SiteSqlDto : IGenericIdSqlDto
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public int BusinessUnitId { get; set; }
[ExcludeFromCodeCoverage]
private SiteSqlDto()
{
}
public SiteSqlDto(int id, string name, string address, int businessUnitId)
{
Id = id;
Name = name;
Address = address;
BusinessUnitId = businessUnitId;
}
}

@ -0,0 +1,25 @@
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
namespace espacecollab.backend.infrastructure.sql.dtos;
[Table("technologie")]
public class TechnologieSqlDto : IGenericIdSqlDto
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
[ExcludeFromCodeCoverage]
private TechnologieSqlDto()
{
}
public TechnologieSqlDto(int id, string name)
{
Id = id;
Name = name;
}
}

@ -0,0 +1,8 @@
namespace espacecollab.backend.infrastructure.sql.dtos.Values;
public enum EnumGenreSql
{
MASCULIN,
FEMININ,
AUTRE
}

@ -0,0 +1,11 @@
namespace espacecollab.backend.infrastructure.sql.dtos.Values;
public enum EnumIssueSql
{
VALIDEE,
PROLONGEE_COLLAB,
PROLONGEE_APSIDE,
ARRETEE_COLLAB,
ARRETEE_APSIDE,
INDETERMINEE
}

@ -0,0 +1,9 @@
namespace espacecollab.backend.infrastructure.sql.dtos.Values;
public enum EnumStatutSql
{
CADRE,
NONCADRE,
ALTERNANT,
STAGIAIRE
}

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,53 @@
using espacecollab.backend.infrastructure.sql.dtos;
using espacecollab.backend.infrastructure.sql.Options;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
namespace espacecollab.backend.infrastructure.sql;
public class MainDbContext : DbContext
{
private IOptions<SqlOption> SqlSettings { get; }
public MainDbContext(IOptions<SqlOption> sqlSettings)
{
SqlSettings = sqlSettings;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMySql(SqlSettings.Value.ConnectionString,
ServerVersion.AutoDetect(SqlSettings.Value.ConnectionString))
.EnableSensitiveDataLogging();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<BusinessUnitSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder.Entity<AgenceSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder.Entity<FonctionSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder.Entity<TechnologieSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder.Entity<PeriodeEssaiSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder
.Entity<PeriodeEssaiSqlDto>()
.Property(e => e.Issue)
.HasConversion<string>();
modelBuilder.Entity<CollaborateurSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder
.Entity<CollaborateurSqlDto>()
.Property(e => e.Gender)
.HasConversion<string>();
modelBuilder
.Entity<CollaborateurSqlDto>()
.Property(e => e.Status)
.HasConversion<string>();
modelBuilder.Entity<ReferencementSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
}
}

@ -0,0 +1,13 @@
namespace espacecollab.backend.infrastructure.sql.Options;
public class SqlOption
{
public static string Key => "Sql";
public bool LoadFake { get; set; }
public string ConnectionString { get; set; }
public SqlOption()
{
ConnectionString = string.Empty;
}
}

@ -0,0 +1,14 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.sql.Repository;
public class AgenceSqlRepository : GenericSqlRepository<AgenceSqlDto>, IAgenceRepository
{
public AgenceSqlRepository(MainDbContext context) : base(context)
{
}
public IList<AgenceSqlDto> GetAgencesByBusinessUnit(int businessUnitId)
=> Context.Set<AgenceSqlDto>().Where(bu => bu.BusinessUnitId == businessUnitId).ToList();
}

@ -0,0 +1,13 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.sql.Repository;
public class BusinessUnitSqlRepository : GenericSqlRepository<BusinessUnitSqlDto>, IBusinessUnitRepository
{
public BusinessUnitSqlRepository(MainDbContext context) : base(context)
{
}
}

@ -0,0 +1,18 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.sql.Repository;
public class CollaborateurSqlRepository : GenericSqlRepository<CollaborateurSqlDto>, ICollaborateurRepository
{
public CollaborateurSqlRepository(MainDbContext context) : base(context)
{
Context = context;
}
public IList<CollaborateurSqlDto> GetCollaborateursByBusinessUnit(int businessUnitId)
=> Context.Set<CollaborateurSqlDto>().Where(collaborateur => collaborateur.BusinessUnitId == businessUnitId).ToList();
public CollaborateurSqlDto? GetCollaborateurByApsideMail(string apsideMail)
=> Context?.Set<CollaborateurSqlDto>().SingleOrDefault(collaborateur => collaborateur.ApsideMail == apsideMail);
}

@ -0,0 +1,11 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.sql.Repository;
public class FonctionSqlRepository : GenericSqlRepository<FonctionSqlDto>, IFonctionRepository
{
public FonctionSqlRepository(MainDbContext context) : base(context)
{
}
}

@ -0,0 +1,52 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.Repository;
public class GenericSqlRepository<T> : IGenericRepository<T> where T : class, IGenericIdSqlDto
{
protected MainDbContext Context { get; set; }
public GenericSqlRepository(MainDbContext context)
{
Context = context;
}
public virtual T? Add(T entity)
{
Context.Set<T>().Add(entity);
Context.SaveChanges();
return entity;
}
public virtual bool Delete(int entityId)
{
T? entity = GetById(entityId);
if (entity == null)
return false;
Context.Set<T>().Remove(entity);
return Context.SaveChanges() == 1;
}
public virtual IEnumerable<T> GetAll()
{
return Context.Set<T>().ToList();
}
public virtual T? GetById(int id)
{
return Context.Set<T>().SingleOrDefault(entity => entity.Id == id);
}
public virtual T? Update(T entity)
{
Context.ChangeTracker.Clear();
Context.Set<T>().Update(entity);
Context.SaveChanges();
return GetById(entity.Id);
}
}

@ -0,0 +1,11 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.sql.Repository;
public class PeriodeEssaiSqlRepository: GenericSqlRepository<PeriodeEssaiSqlDto>, IPeriodeEssaiRepository
{
public PeriodeEssaiSqlRepository(MainDbContext context) : base(context)
{
}
}

@ -0,0 +1,11 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.sql.Repository;
public class ReferencementSqlRepository: GenericSqlRepository<ReferencementSqlDto>, IReferencementRepository
{
public ReferencementSqlRepository(MainDbContext context) : base(context)
{
}
}

@ -0,0 +1,11 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.sql.Repository;
public class TechnologieSqlRepository : GenericSqlRepository<TechnologieSqlDto>, ITechnologieRepository
{
public TechnologieSqlRepository(MainDbContext context) : base(context)
{
}
}

@ -0,0 +1,161 @@
DROP DATABASE IF EXISTS collaborateur_epa;
CREATE DATABASE IF NOT EXISTS collaborateur_epa /*!40100 DEFAULT CHARACTER SET latin1 */;
USE collaborateur_epa;
DROP TABLE IF EXISTS Agence;
CREATE TABLE IF NOT EXISTS Agence(
Id int NOT NULL AUTO_INCREMENT,
Name varchar(100) NOT NULL UNIQUE,
PRIMARY KEY (Id)
);
DROP TABLE IF EXISTS BusinessUnit;
CREATE TABLE IF NOT EXISTS BusinessUnit(
Id int NOT NULL AUTO_INCREMENT,
Name varchar(100) NOT NULL UNIQUE,
AgenceId int NOT NULL,
CONSTRAINT FK_BUSINESS_UNIT_AGENCE FOREIGN KEY (AgenceId) references Agence(Id),
PRIMARY KEY (Id)
);
DROP TABLE IF EXISTS Site;
CREATE TABLE IF NOT EXISTS Site(
Id int NOT NULL AUTO_INCREMENT,
Name varchar(100) NOT NULL UNIQUE,
Address varchar(200) NOT NULL,
BusinessUnitId int NOT NULL,
CONSTRAINT FK_SITE_BUSINESS_UNIT FOREIGN KEY (BusinessUnitId) references BusinessUnit(Id),
PRIMARY KEY (Id)
);
DROP TABLE IF EXISTS Projet;
CREATE TABLE IF NOT EXISTS Projet(
Id int NOT NULL AUTO_INCREMENT,
Name varchar(100) NOT NULL UNIQUE,
Client varchar(100) NOT NULL,
Description varchar(100) NOT NULL,
StartingDate date NOT NULL,
EndingDate date NOT NULL,
PRIMARY KEY (Id)
);
DROP TABLE IF EXISTS Technologie;
CREATE TABLE IF NOT EXISTS Technologie(
Id int NOT NULL UNIQUE,
Name varchar(100) NOT NULL UNIQUE,
PRIMARY KEY (Id)
);
DROP TABLE IF EXISTS Fonction;
CREATE TABLE IF NOT EXISTS Fonction(
Id int NOT NULL UNIQUE,
intitule varchar(100) NOT NULL UNIQUE,
PRIMARY KEY (Id)
);
DROP TABLE IF EXISTS Collaborateur;
CREATE TABLE IF NOT EXISTS Collaborateur(
Id int NOT NULL AUTO_INCREMENT,
Name varchar(100) NOT NULL,
FirstName varchar(100) NOT NULL,
BirthDate date NOT NULL,
Gender ENUM('masculin','feminin','autre') NOT NULL DEFAULT 'masculin',
Status ENUM('cadre','noncadre','alternant','stagiaire') NOT NULL DEFAULT 'noncadre',
ChildrenNumber smallint NOT NULL,
Address varchar(200) NOT NULL,
Telephone varchar(15) NOT NULL,
PersonalMail varchar(100) NOT NULL,
ApsideMail varchar(100) NOT NULL,
ResignationDate date,
BusinessUnitId int NOT NUll,
ReferrerId int,
CONSTRAINT FK_COLLABORATEUR_BUSINESSUNIT FOREIGN KEY (BusinessUnitId) REFERENCES BusinessUnit(Id),
CONSTRAINT FK_COLLABORATEUR_PARRAIN FOREIGN KEY (ReferrerId) REFERENCES Collaborateur(Id),
PRIMARY KEY (Id)
);
DROP TABLE IF EXISTS PeriodeEssai;
CREATE TABLE IF NOT EXISTS PeriodeEssai(
Id int NOT NULL AUTO_INCREMENT,
StartingDate date NOT NULL,
PlannedEndingDate date NOT NULL,
RealEndingDate date NOT NULL,
Comment varchar(100) NOT NULL,
Issue ENUM('VALIDEE','PROLONGEE_COLLAB','PROLONGEE_APSIDE','ARRETEE_COLLAB','ARRETEE_APSIDE') NOT NULL,
CollaborateurId int NOT NULL,
CONSTRAINT FK_COLLABORATEUR_PERIODEESSAI FOREIGN KEY (CollaborateurId) REFERENCES Collaborateur(Id),
PRIMARY KEY (Id)
);
DROP TABLE IF EXISTS Referencement;
CREATE TABLE IF NOT EXISTS Referencement(
Id int NOT NULL AUTO_INCREMENT,
StartingDate date NOT NULL,
EndingDate date NOT NULL,
ReferredId int NOT NULL,
ReferrerId int NOT NULL,
CONSTRAINT FK_COLLABORATEUR_REFERE FOREIGN KEY (ReferredId) REFERENCES Collaborateur(Id),
CONSTRAINT FK_COLLABORATEUR_REFERENT FOREIGN KEY (ReferrerId) REFERENCES Collaborateur(Id),
PRIMARY KEY (Id)
);
DROP TABLE IF EXISTS CollaborateurEstFonction;
CREATE TABLE IF NOT EXISTS CollaborateurEstFonction(
CollaborateurId int NOT NULL,
FonctionId int NOT NULL,
PRIMARY KEY (CollaborateurId,FonctionId),
CONSTRAINT FK_COLLABORATEUR_FONCTION FOREIGN KEY (CollaborateurId) REFERENCES Collaborateur(Id),
CONSTRAINT FK_FONCTION_COLLABORATEUR FOREIGN KEY (FonctionId) REFERENCES Fonction(Id)
);
DROP TABLE IF EXISTS CollaborateurAppartientBusinessUnit;
CREATE TABLE IF NOT EXISTS CollaborateurAppartientBusinessUnit(
CollaborateurId int NOT NULL,
BusinessUnitId int NOT NULL,
PRIMARY KEY (CollaborateurId,BusinessUnitId),
CONSTRAINT FK_COLLABORATEUR_BUSINESS_UNIT FOREIGN KEY (CollaborateurId) REFERENCES Collaborateur(Id),
CONSTRAINT FK_BUSINESS_UNIT_COLLABORATEUR FOREIGN KEY (BusinessUnitId) REFERENCES BusinessUnit(Id)
);
DROP TABLE IF EXISTS CollaborateurEffectuePeriodeEssai;
CREATE TABLE IF NOT EXISTS CollaborateurEffectuePeriodeEssai(
CollaborateurId int NOT NULL,
PeriodeEssaiId int NOT NULL,
PRIMARY KEY (CollaborateurId,PeriodeEssaiId),
CONSTRAINT FK_COLLABORATEUR_PERIODE_ESSAI FOREIGN KEY (CollaborateurId) REFERENCES Collaborateur(Id),
CONSTRAINT FK_PERIODE_ESSAI_COLLABORATEUR FOREIGN KEY (PeriodeEssaiId) REFERENCES PeriodeEssai(Id)
);
DROP TABLE IF EXISTS SiteDeveloppeProjet;
CREATE TABLE IF NOT EXISTS SiteDeveloppeProjet(
SiteId int NOT NULL,
ProjetId int NOT NULL,
PRIMARY KEY (SiteId,ProjetId),
CONSTRAINT FK_SITE_PROJET FOREIGN KEY (SiteId) REFERENCES Site(Id),
CONSTRAINT FK_PROJET_SITE FOREIGN KEY (ProjetId) REFERENCES Projet(Id)
);
DROP TABLE IF EXISTS ProjetUtiliseTechnologie;
CREATE TABLE IF NOT EXISTS ProjetUtiliseTechnologie(
ProjetId int NOT NULL,
TechnologieId int NOT NULL,
PRIMARY KEY (ProjetId,TechnologieId),
CONSTRAINT FK_PROJET_TECHNOLOGIE FOREIGN KEY (ProjetId) REFERENCES Projet(Id),
CONSTRAINT FK_TECHNOLOGIE_PROJET FOREIGN KEY (TechnologieId) REFERENCES Technologie(Id)
);
DROP TABLE IF EXISTS CollaborateurCollaboreProjet;
CREATE TABLE IF NOT EXISTS CollaborateurCollaboreProjet(
CollaborateurId int NOT NULL,
ProjetId int NOT NULL,
isManager boolean NOT NULL,
PRIMARY KEY (CollaborateurId,ProjetId),
CONSTRAINT FK_COLLABORATEUR_COLLABORE_PROJET FOREIGN KEY (CollaborateurId) REFERENCES Collaborateur(Id),
CONSTRAINT FK_PROJET_COLLABORE_COLLABORATEUR FOREIGN KEY (ProjetId) REFERENCES Projet(Id)
);
INSERT INTO Agence(Id, Name) VALUES (1,'Agence1');
INSERT INTO BusinessUnit(Id, Name, AgenceId) VALUES (1,'BusinessUnit1',1);
INSERT INTO Collaborateur(Id, Name, FirstName, BirthDate, Gender, Status, ChildrenNumber, Address, Telephone, PersonalMail,
ApsideMail, ResignationDate, BusinessUnitId, ReferrerId)
VALUES (1,'Collab1','Collab1','2000-30-08','masculin','cadre',0,'adresse','tel','pmail','amail',NULL,1,NULL);

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\espacecollab.backend.infrastructure.interfaces\espacecollab.backend.infrastructure.interfaces.csproj" />
<ProjectReference Include="..\espacecollab.backend.infrastructure.sql.dtos\espacecollab.backend.infrastructure.sql.dtos.csproj" />
</ItemGroup>
</Project>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save