Compare commits

..

1 Commits

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

@ -1,64 +0,0 @@
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);
}
}

@ -1,24 +0,0 @@
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);
}
}

@ -1,28 +0,0 @@
<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>

@ -1,25 +0,0 @@
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);
}
}

@ -1,68 +0,0 @@
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);
}
}
}

@ -1,16 +0,0 @@
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)
{
}
}
}

@ -1,94 +0,0 @@
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);
}
}

@ -1,12 +0,0 @@
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)
{
}
}
}

@ -1,17 +0,0 @@
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);
}

@ -1,11 +0,0 @@
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)
{
}
}

@ -1,13 +0,0 @@
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)
{
}
}

@ -1,12 +0,0 @@
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)
{
}
}
}

@ -1,29 +0,0 @@
#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"]

@ -1,16 +0,0 @@
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>();
});
}

@ -1,38 +0,0 @@
{
"$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
}
}
}

@ -1,42 +0,0 @@
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>();
}
}
}

@ -1,57 +0,0 @@
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();
});
}
}

@ -1,14 +0,0 @@
{
"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
}
}

@ -1,26 +0,0 @@
<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>

@ -1,8 +0,0 @@
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;
}

@ -1,8 +0,0 @@
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;
}

@ -1,10 +0,0 @@
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;
}

@ -1,8 +0,0 @@
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;
}

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

@ -1,15 +0,0 @@
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);
}
}

@ -1,15 +0,0 @@
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);
}
}

@ -1,22 +0,0 @@
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);
}
}

@ -1,29 +0,0 @@
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,
};
}
}

@ -1,31 +0,0 @@
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,
};
}
}

@ -1,15 +0,0 @@
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);
}
}

@ -1,22 +0,0 @@
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);
}
}

@ -1,15 +0,0 @@
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);
}
}

@ -1,15 +0,0 @@
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);
}
}

@ -1,9 +0,0 @@
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;
}

@ -1,12 +0,0 @@
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;
}

@ -1,8 +0,0 @@
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;
}

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

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

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

@ -1,13 +0,0 @@
<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>

@ -1,16 +0,0 @@
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);
}

@ -1,14 +0,0 @@
<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>

@ -1,22 +0,0 @@
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());
}
}

@ -1,15 +0,0 @@
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)
{}
}

@ -1,100 +0,0 @@
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();
}
}

@ -1,14 +0,0 @@
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)
{
}
}

@ -1,66 +0,0 @@
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);
}
}

@ -1,14 +0,0 @@
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)
{
}
}

@ -1,18 +0,0 @@
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;
}
}

@ -1,14 +0,0 @@
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)
{
}
}

@ -1,15 +0,0 @@
<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>

@ -1,16 +0,0 @@
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")
// };
// }
//}

@ -1,21 +0,0 @@
//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();
// }
//}

@ -1,35 +0,0 @@
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
}

@ -1,16 +0,0 @@
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")
};
}
}

@ -1,17 +0,0 @@
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)
};
}
}

@ -1,48 +0,0 @@
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);
}
}

@ -1,14 +0,0 @@
<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>

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

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

@ -1,9 +0,0 @@
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);
}

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

@ -1,12 +0,0 @@
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);
}

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

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

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

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

@ -1,13 +0,0 @@
<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>

@ -1,28 +0,0 @@
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;
}
}

@ -1,26 +0,0 @@
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;
}
}

@ -1,21 +0,0 @@
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;
}
}

@ -1,22 +0,0 @@
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;
}
}

@ -1,20 +0,0 @@
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;
}
}

@ -1,54 +0,0 @@
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;
}
}

@ -1,28 +0,0 @@
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;
}
}
}

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

@ -1,37 +0,0 @@
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;
}
}

@ -1,33 +0,0 @@
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;
}
}

@ -1,20 +0,0 @@
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;
}
}

@ -1,31 +0,0 @@
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;
}
}

@ -1,20 +0,0 @@
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;
}
}

@ -1,29 +0,0 @@
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;
}
}

@ -1,25 +0,0 @@
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;
}
}

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

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

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

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

@ -1,53 +0,0 @@
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();
}
}

@ -1,13 +0,0 @@
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;
}
}

@ -1,14 +0,0 @@
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();
}

@ -1,13 +0,0 @@
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)
{
}
}

@ -1,18 +0,0 @@
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);
}

@ -1,11 +0,0 @@
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)
{
}
}

@ -1,52 +0,0 @@
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);
}
}

@ -1,11 +0,0 @@
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)
{
}
}

@ -1,11 +0,0 @@
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)
{
}
}

@ -1,11 +0,0 @@
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)
{
}
}

@ -1,161 +0,0 @@
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);

@ -1,18 +0,0 @@
<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