Merge pull request 'Mise en place d'entités' (#4) from task/tu into develop

Reviewed-on: Clement.Ferrere/Collaborateur_Epa_Back#4
pull/6/head^2
Alexandre Ruiz 3 years ago
commit d7e4795320
  1. 64
      Collaborateur_Epa_Back/espacecollab.backend.api.tests/BaseControllerTest.cs
  2. 24
      Collaborateur_Epa_Back/espacecollab.backend.api.tests/CollaborateursControllerTest.cs
  3. 28
      Collaborateur_Epa_Back/espacecollab.backend.api.tests/espacecollab.backend.api.tests.csproj
  4. 11
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/AgencesController.cs
  5. 2
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/BaseController.cs
  6. 11
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/BusinessUnitController.cs
  7. 28
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/BusinessUnitsController.cs
  8. 13
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/CollaborateursController.cs
  9. 11
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/FonctionController.cs
  10. 4
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/FonctionsController.cs
  11. 17
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/IBaseController.cs
  12. 11
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/PeriodeEssaiController.cs
  13. 12
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/TechnologiesController.cs
  14. 7
      Collaborateur_Epa_Back/espacecollab.backend.api/Program.cs
  15. 12
      Collaborateur_Epa_Back/espacecollab.backend.api/Register.cs
  16. 7
      Collaborateur_Epa_Back/espacecollab.backend.api/Startup.cs
  17. 8
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/BusinessUnitApiDto.cs
  18. 10
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/CollaborateurApiDto.cs
  19. 9
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/EnumGenreApi.cs
  20. 10
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/EnumStatutApi.cs
  21. 8
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/FonctionApiDto.cs
  22. 6
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Interfaces/IGenericIdApiDto.cs
  23. 7
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Interfaces/IGenericIdSqlDto.cs
  24. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/BusinessUnitMapper.cs
  25. 16
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/CollaborateurApiDtoMapper.cs
  26. 10
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/EnumGenreMapper.cs
  27. 10
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/EnumStatutMapper.cs
  28. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/FonctionMapper.cs
  29. 22
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/PeriodeEssaiMapper.cs
  30. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/TechnologieMapper.cs
  31. 9
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/PeriodeEssaiApiDto.cs
  32. 8
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/TechnologieApiDto.cs
  33. 8
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Values/EnumGenreApi.cs
  34. 10
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Values/EnumIssueApi.cs
  35. 9
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Values/EnumStatutApi.cs
  36. 7
      Collaborateur_Epa_Back/espacecollab.backend.appservices.interfaces/IGenericsServices.cs
  37. 2
      Collaborateur_Epa_Back/espacecollab.backend.appservices/AgenceService.cs
  38. 20
      Collaborateur_Epa_Back/espacecollab.backend.appservices/BusinessUnitService.cs
  39. 35
      Collaborateur_Epa_Back/espacecollab.backend.appservices/CollaborateursService.cs
  40. 36
      Collaborateur_Epa_Back/espacecollab.backend.appservices/CollaborateursServices.cs
  41. 14
      Collaborateur_Epa_Back/espacecollab.backend.appservices/FonctionService.cs
  42. 12
      Collaborateur_Epa_Back/espacecollab.backend.appservices/GenericsServices.cs
  43. 14
      Collaborateur_Epa_Back/espacecollab.backend.appservices/PeriodeEssaiService.cs
  44. 14
      Collaborateur_Epa_Back/espacecollab.backend.appservices/TechnologieServices.cs
  45. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeAgenceRepository.cs
  46. 21
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeBusinessUnitRepository.cs
  47. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeCollaborateurRepository.cs
  48. 16
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeFonctionRepository.cs
  49. 17
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakePeriodeEssaiRepository.cs
  50. 9
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/GenericFakeRepository.cs
  51. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IAgenceRepository.cs
  52. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IBusinessUnitRepository.cs
  53. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/ICollaborateurRepository.cs
  54. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IFonctionRepository.cs
  55. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IGenericRepository.cs
  56. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IPeriodeEssaiRepository.cs
  57. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IProjetRepository.cs
  58. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IReferencementRepository.cs
  59. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/ITechnologieRepository.cs
  60. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/AgenceSqlDto.cs
  61. 9
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/BusinessUnitSqlDto.cs
  62. 9
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurAppartientBusinessUnitSqlDto.cs
  63. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurCollaboreProjetSqlDto.cs
  64. 9
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurEstFonctionSqlDto.cs
  65. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurSqlDto.cs
  66. 6
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/FonctionSqlDto.cs
  67. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Interfaces/IGenericIdSqlDto.cs
  68. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/PeriodeEssaiSqlDto.cs
  69. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/ProjetSqlDto.cs
  70. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/ProjetUtiliseTechnologieSqlDto.cs
  71. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/ReferencementSqlDto.cs
  72. 10
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/SiteDeveloppeProjetSqlDto.cs
  73. 10
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/SiteSqlDto.cs
  74. 12
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/TechnologieSqlDto.cs
  75. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Values/EnumGenreSql.cs
  76. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Values/EnumIssueSql.cs
  77. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Values/EnumStatutSql.cs
  78. 17
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/MainDbContext.cs
  79. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Options/SqlOption.cs
  80. 14
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/BusinessUnitSqlRepository.cs
  81. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/CollaborateurSqlRepository.cs
  82. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/FonctionSqlRepository.cs
  83. 19
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/GenericSqlRepository.cs
  84. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/PeriodeEssaiSqlRepository.cs
  85. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/TechnologieSqlRepository.cs
  86. 9
      Collaborateur_Epa_Back/espacecollab.backend.sln

@ -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), 2, 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), 2, 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.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<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,11 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
namespace espacecollab.backend.api.Controllers;
public class AgenceController : BaseController<AgenceApiDto>
{
public AgenceController(AgenceService agenceService) : base(agenceService)
{
}
}

@ -6,7 +6,7 @@ namespace espacecollab.backend.api.Controllers
{ {
[Route("api/[controller]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public abstract class BaseController<TO> : Controller where TO : class, IGenericIdApiDto public abstract class BaseController<TO> : Controller, IBaseController<TO> where TO : class, IGenericIdApiDto
{ {
protected IGenericsServices<TO> Services { get; } protected IGenericsServices<TO> Services { get; }

@ -0,0 +1,11 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
namespace espacecollab.backend.api.Controllers;
public class BusinessUnitController : BaseController<BusinessUnitApiDto>
{
public BusinessUnitController(BusinessUnitService businessUnitService) : base(businessUnitService)
{
}
}

@ -0,0 +1,28 @@
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>
{
private BusinessUnitService BusinessUnitServices { get; }
public BusinessUnitsController(BusinessUnitService businessUnitServices) : base(businessUnitServices)
{
BusinessUnitServices = businessUnitServices;
}
[HttpGet("agence/{agenceId:int:min(1)}")]
public ActionResult<IEnumerable<BusinessUnitApiDto>> GetBusinessUnitsByAgence(uint agenceId)
{
IEnumerable<BusinessUnitApiDto> businessUnits = BusinessUnitServices.GetBusinessUnitsByAgence(agenceId);
if (!businessUnits.Any())
return NotFound();
return Ok(businessUnits);
}
}
}

@ -2,15 +2,13 @@
using espacecollab.backend.appservices.dtos; using espacecollab.backend.appservices.dtos;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace espacecollab.backend.api.Controllers namespace espacecollab.backend.api.Controllers;
public class CollaborateursController : BaseController<CollaborateurApiDto>
{ {
//[Route("api/[controller]")] private CollaborateursService CollaborateursServices { get; }
//[ApiController]
public class CollaborateursController : BaseController<CollaborateurApiDto>
{
private CollaborateursServices CollaborateursServices { get; }
public CollaborateursController(CollaborateursServices collaborateursServices) : base(collaborateursServices) public CollaborateursController(CollaborateursService collaborateursServices) : base(collaborateursServices)
{ {
CollaborateursServices = collaborateursServices; CollaborateursServices = collaborateursServices;
} }
@ -44,5 +42,4 @@ namespace espacecollab.backend.api.Controllers
return Ok(collaborateur); return Ok(collaborateur);
} }
}
} }

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

@ -3,9 +3,9 @@ using espacecollab.backend.appservices.dtos;
namespace espacecollab.backend.api.Controllers namespace espacecollab.backend.api.Controllers
{ {
public class AgenceController : BaseController<AgenceApiDto> public class FonctionsController : BaseController<FonctionApiDto>
{ {
public AgenceController(AgenceService agenceService) : base(agenceService) 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 PeriodeEssaiController : BaseController<PeriodeEssaiApiDto>
{
public PeriodeEssaiController(PeriodeEssaiService periodeEssaiService) : base(periodeEssaiService)
{
}
}

@ -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)
{
}
}
}

@ -1,7 +1,7 @@
namespace espacecollab.backend.api namespace espacecollab.backend.api;
public static class Program
{ {
public static class Program
{
public static void Main(string[] args) public static void Main(string[] args)
{ {
CreateHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
@ -13,5 +13,4 @@ namespace espacecollab.backend.api
{ {
webBuilder.UseStartup<Startup>(); webBuilder.UseStartup<Startup>();
}); });
}
} }

@ -12,19 +12,29 @@ internal static class Register
public static void InjectDependencies(IServiceCollection services, SqlOption contextOptions) public static void InjectDependencies(IServiceCollection services, SqlOption contextOptions)
{ {
services.AddCors(); services.AddCors();
services.AddScoped<CollaborateursServices>(); services.AddScoped<CollaborateursService>();
services.AddScoped<AgenceService>(); services.AddScoped<AgenceService>();
services.AddScoped<BusinessUnitService>();
services.AddScoped<FonctionService>();
services.AddScoped<PeriodeEssaiService>();
if (contextOptions.LoadFake) if (contextOptions.LoadFake)
{ {
services.AddSingleton<ICollaborateurRepository, FakeCollaborateurRepository>(); services.AddSingleton<ICollaborateurRepository, FakeCollaborateurRepository>();
services.AddSingleton<IAgenceRepository, FakeAgenceRepository>(); services.AddSingleton<IAgenceRepository, FakeAgenceRepository>();
services.AddSingleton<IBusinessUnitRepository, FakeBusinessUnitRepository>();
services.AddSingleton<IFonctionRepository, FakeFonctionRepository>();
services.AddSingleton<IPeriodeEssaiRepository, FakePeriodeEssaiRepository>();
} }
else else
{ {
services.AddScoped<MainDbContext>(); services.AddScoped<MainDbContext>();
services.AddScoped<ICollaborateurRepository, CollaborateurSqlRepository>(); services.AddScoped<ICollaborateurRepository, CollaborateurSqlRepository>();
services.AddScoped<IAgenceRepository, AgenceSqlRepository>(); services.AddScoped<IAgenceRepository, AgenceSqlRepository>();
services.AddScoped<IBusinessUnitRepository, BusinessUnitSqlRepository>();
services.AddScoped<IFonctionRepository, FonctionSqlRepository>();
services.AddScoped<ITechnologieRepository, TechnologieSqlRepository>();
services.AddScoped<IPeriodeEssaiRepository, PeriodeEssaiSqlRepository>();
} }
} }
} }

@ -1,10 +1,10 @@
using espacecollab.backend.infrastructure.sql.Options; using espacecollab.backend.infrastructure.sql.Options;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace espacecollab.backend.api namespace espacecollab.backend.api;
public class Startup
{ {
public class Startup
{
public IConfiguration Configuration { get; } public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration) public Startup(IConfiguration configuration)
{ {
@ -54,5 +54,4 @@ namespace espacecollab.backend.api
endpoints.MapControllers(); endpoints.MapControllers();
}); });
} }
}
} }

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

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

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

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

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

@ -1,7 +0,0 @@
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 BusinessUnitMapper
{
public static BusinessUnitApiDto ToApi(this BusinessUnitSqlDto businessUnitSqlDto)
{
return new BusinessUnitApiDto((uint)businessUnitSqlDto.Id, businessUnitSqlDto.Name, (uint)businessUnitSqlDto.AgenceId);
}
public static BusinessUnitSqlDto ToSql(this BusinessUnitApiDto businessUnitApiDto)
{
return new BusinessUnitSqlDto((int)businessUnitApiDto.Id, businessUnitApiDto.Name, (int)businessUnitApiDto.AgenceId);
}
}

@ -1,24 +1,22 @@
using espacecollab.backend.infrastructure.sql.dtos; using espacecollab.backend.infrastructure.sql.dtos;
using System.Globalization;
namespace espacecollab.backend.appservices.dtos.Mappers namespace espacecollab.backend.appservices.dtos.Mappers;
public static class CollaborateurMapper
{ {
public static class CollaborateurMapper
{
public static CollaborateurApiDto ToApi(this CollaborateurSqlDto collaborateurSql) public static CollaborateurApiDto ToApi(this CollaborateurSqlDto collaborateurSql)
{ {
return new CollaborateurApiDto((uint)collaborateurSql.Id, collaborateurSql.Name, collaborateurSql.FirstName, return new CollaborateurApiDto((uint)collaborateurSql.Id, collaborateurSql.Name, collaborateurSql.FirstName,
collaborateurSql.BirthDate.ToShortDateString(), collaborateurSql.Gender.ToEnumGenreApi(), collaborateurSql.Status.ToEnumStatutApi(), collaborateurSql.ChildrenNumber, collaborateurSql.BirthDate, collaborateurSql.Gender.ToEnumGenreApi(), collaborateurSql.Status.ToEnumStatutApi(), collaborateurSql.ChildrenNumber,
collaborateurSql.Address, collaborateurSql.Telephone, collaborateurSql.PersonalMail, collaborateurSql.ApsideMail, collaborateurSql.Address, collaborateurSql.Telephone, collaborateurSql.PersonalMail, collaborateurSql.ApsideMail,
collaborateurSql.ResignationDate.ToShortDateString(), collaborateurSql.ReferrerId, collaborateurSql.BusinessUnitId); collaborateurSql.ResignationDate, collaborateurSql.ReferrerId, collaborateurSql.BusinessUnitId);
} }
public static CollaborateurSqlDto ToSql(this CollaborateurApiDto collaborateurApi) public static CollaborateurSqlDto ToSql(this CollaborateurApiDto collaborateurApi)
{ {
return new CollaborateurSqlDto((int)collaborateurApi.Id, collaborateurApi.Name, collaborateurApi.FirstName, return new CollaborateurSqlDto((int)collaborateurApi.Id, collaborateurApi.Name, collaborateurApi.FirstName,
DateTime.ParseExact(collaborateurApi.BirthDate,"dd/MM/yyyy",CultureInfo.InvariantCulture), collaborateurApi.Gender.ToEnumGenreSql(), collaborateurApi.Status.ToEnumStatutSql(), collaborateurApi.ChildrenNumber, collaborateurApi.BirthDate, collaborateurApi.Gender.ToEnumGenreSql(), collaborateurApi.Status.ToEnumStatutSql(), collaborateurApi.ChildrenNumber,
collaborateurApi.Address, collaborateurApi.Telephone, collaborateurApi.PersonalMail, collaborateurApi.ApsideMail, collaborateurApi.Address, collaborateurApi.Telephone, collaborateurApi.PersonalMail, collaborateurApi.ApsideMail,
DateTime.ParseExact(collaborateurApi.ResignationDate, "dd/MM/yyyy", CultureInfo.InvariantCulture), collaborateurApi.ReferrerId, collaborateurApi.BusinessUnitId); collaborateurApi.ResignationDate, collaborateurApi.ReferrerId, collaborateurApi.BusinessUnitId);
}
} }
} }

@ -1,9 +1,10 @@
using espacecollab.backend.infrastructure.sql.dtos.Values; using espacecollab.backend.appservices.dtos.Values;
using espacecollab.backend.infrastructure.sql.dtos.Values;
namespace espacecollab.backend.appservices.dtos.Mappers namespace espacecollab.backend.appservices.dtos.Mappers;
public static class EnumGenreMapper
{ {
public static class EnumGenreMapper
{
public static EnumGenreApi ToEnumGenreApi(this EnumGenreSql enumGenreSql) public static EnumGenreApi ToEnumGenreApi(this EnumGenreSql enumGenreSql)
{ {
return enumGenreSql switch return enumGenreSql switch
@ -25,5 +26,4 @@ namespace espacecollab.backend.appservices.dtos.Mappers
_ => EnumGenreSql.AUTRE, _ => EnumGenreSql.AUTRE,
}; };
} }
}
} }

@ -1,9 +1,10 @@
using espacecollab.backend.infrastructure.sql.dtos.Values; using espacecollab.backend.appservices.dtos.Values;
using espacecollab.backend.infrastructure.sql.dtos.Values;
namespace espacecollab.backend.appservices.dtos.Mappers namespace espacecollab.backend.appservices.dtos.Mappers;
public static class EnumStatutMapper
{ {
public static class EnumStatutMapper
{
public static EnumStatutApi ToEnumStatutApi(this EnumStatutSql enumStatutSql) public static EnumStatutApi ToEnumStatutApi(this EnumStatutSql enumStatutSql)
{ {
return enumStatutSql switch return enumStatutSql switch
@ -27,5 +28,4 @@ namespace espacecollab.backend.appservices.dtos.Mappers
_ => EnumStatutSql.NONCADRE, _ => 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 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,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,10 @@
namespace espacecollab.backend.appservices.dtos.Values;
public enum EnumIssueApi
{
VALIDEE,
PROLONGEE_COLLAB,
PROLONGEE_APSIDE,
ARRETEE_COLLAB,
ARRETEE_APSIDE
}

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

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

@ -8,7 +8,7 @@ namespace espacecollab.backend.appservices;
public class AgenceService : GenericsServices<AgenceSqlDto, AgenceApiDto> public class AgenceService : GenericsServices<AgenceSqlDto, AgenceApiDto>
{ {
public AgenceService(IAgenceRepository agenceRepository) public AgenceService(IAgenceRepository agenceRepository)
:base(agenceRepository, AgenceMapper.ToApi, AgenceMapper.ToSql) : base(agenceRepository, AgenceMapper.ToApi, AgenceMapper.ToSql)
{ {
} }
} }

@ -0,0 +1,20 @@
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>
{
private IBusinessUnitRepository BusinessUnitRepository { get; }
public BusinessUnitService(IBusinessUnitRepository businessUnitRepository)
:base(businessUnitRepository, BusinessUnitMapper.ToApi, BusinessUnitMapper.ToSql)
{}
public IEnumerable<BusinessUnitApiDto> GetBusinessUnitsByAgence(uint agenceId)
{
return BusinessUnitRepository.GetBusinessUnitsByAgence((int)agenceId).Select(bu => bu.ToApi());
}
}

@ -0,0 +1,35 @@
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; }
public CollaborateursService(ICollaborateurRepository collaborateurRepository)
: base(collaborateurRepository, CollaborateurMapper.ToApi, CollaborateurMapper.ToSql)
{
CollaborateurRepository = collaborateurRepository;
}
public IEnumerable<CollaborateurApiDto> GetCollaborateursByBusinessUnit(uint businessUnitId)
{
return CollaborateurRepository.GetCollaborateursByBusinessUnit((int)businessUnitId).Select(collaborateurSql => collaborateurSql.ToApi());
}
public IEnumerable<CollaborateurApiDto> GetCollaborateursByReferrer(uint referrerId)
{
return CollaborateurRepository.GetCollaborateursByReferrer((int)referrerId).Select(collaborateurSql => collaborateurSql.ToApi());
}
public CollaborateurApiDto? GetCollaborateurByApsideMail(string apsideMail)
{
if (string.IsNullOrEmpty(apsideMail))
return null;
return CollaborateurRepository.GetCollaborateurByApsideMail(apsideMail)?.ToApi();
}
}

@ -1,36 +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 CollaborateursServices : GenericsServices<CollaborateurSqlDto, CollaborateurApiDto>
{
private ICollaborateurRepository CollaborateurRepository { get; }
public CollaborateursServices(ICollaborateurRepository collaborateurRepository)
: base(collaborateurRepository, CollaborateurMapper.ToApi, CollaborateurMapper.ToSql)
{
CollaborateurRepository = collaborateurRepository;
}
public IEnumerable<CollaborateurApiDto> GetCollaborateursByBusinessUnit(uint businessUnitId)
{
return CollaborateurRepository.GetCollaborateursByBusinessUnit((int)businessUnitId).Select(collaborateurSql => collaborateurSql.ToApi());
}
public IEnumerable<CollaborateurApiDto> GetCollaborateursByReferrer(uint referrerId)
{
return CollaborateurRepository.GetCollaborateursByReferrer((int)referrerId).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)
{
}
}

@ -3,11 +3,11 @@ using espacecollab.backend.appservices.interfaces;
using espacecollab.backend.infrastructure.interfaces; using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces; using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.appservices namespace espacecollab.backend.appservices;
{
public abstract class GenericsServices<T, TO> : IGenericsServices<TO> where T : class, IGenericIdSqlDto public abstract class GenericsServices<T, TO> : IGenericsServices<TO> where T : class, IGenericIdSqlDto
where TO : class, IGenericIdApiDto where TO : class, IGenericIdApiDto
{ {
private Func<T, TO> MapperToApiDto { get; } private Func<T, TO> MapperToApiDto { get; }
private Func<TO, T> MapperToSqlDto { get; } private Func<TO, T> MapperToSqlDto { get; }
@ -47,6 +47,9 @@ namespace espacecollab.backend.appservices
public TO? Update(TO apiDto) public TO? Update(TO apiDto)
{ {
if (GetById(apiDto.Id) == null)
return null;
T sqlDto = MapperToSqlDto(apiDto); T sqlDto = MapperToSqlDto(apiDto);
T? sqlDtoValidation = GenericRepository.Update(sqlDto); T? sqlDtoValidation = GenericRepository.Update(sqlDto);
@ -60,5 +63,4 @@ namespace espacecollab.backend.appservices
{ {
return GenericRepository.Delete((int)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,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)
{
}
}

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

@ -2,10 +2,10 @@
using espacecollab.backend.infrastructure.sql.dtos; using espacecollab.backend.infrastructure.sql.dtos;
using espacecollab.backend.infrastructure.sql.dtos.Values; using espacecollab.backend.infrastructure.sql.dtos.Values;
namespace espacecollab.backend.infrastructure.fake namespace espacecollab.backend.infrastructure.fake;
public class FakeCollaborateurRepository : GenericFakeRepository<CollaborateurSqlDto>, ICollaborateurRepository
{ {
public class FakeCollaborateurRepository : GenericFakeRepository<CollaborateurSqlDto>, ICollaborateurRepository
{
public FakeCollaborateurRepository() public FakeCollaborateurRepository()
{ {
Context = new List<CollaborateurSqlDto> Context = new List<CollaborateurSqlDto>
@ -13,7 +13,6 @@ namespace espacecollab.backend.infrastructure.fake
new(1, "Dupont", "Jean", new DateTime(1980, 12, 10), new(1, "Dupont", "Jean", new DateTime(1980, 12, 10),
EnumGenreSql.MASCULIN, EnumStatutSql.NONCADRE, 0, "1 rue du Louvre, 63000, Clermont-Ferrand", "0660258644", 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), 2, 1), "jean.dupont@gmail.com", "jean.dupont@apside-groupe.com", new DateTime(2023, 12, 17), 2, 1),
new(2, "Michel", "Laura", new DateTime(1985, 08, 12), new(2, "Michel", "Laura", new DateTime(1985, 08, 12),
EnumGenreSql.FEMININ, EnumStatutSql.NONCADRE, 0, "5 rue du Louvre, 63000, Clermont-Ferrand", "0660258644", 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, 1) "laura.michel@gmail.com", "laura.michel@apside-groupe.com", new DateTime(2023, 12, 17), 1, 1)
@ -38,5 +37,4 @@ namespace espacecollab.backend.infrastructure.fake
} }
#endregion #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)
};
}
}

@ -1,11 +1,11 @@
using espacecollab.backend.infrastructure.interfaces; using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces; using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.fake namespace espacecollab.backend.infrastructure.fake;
public class GenericFakeRepository<T> : IGenericRepository<T> where T : class, IGenericIdSqlDto
{ {
public class GenericFakeRepository<T> : IGenericRepository<T> where T : class, IGenericIdSqlDto protected List<T> Context { get; set; } = new();
{
protected List<T> Context { get; set; }
public virtual T? Add(T entity) public virtual T? Add(T entity)
{ {
@ -45,5 +45,4 @@ namespace espacecollab.backend.infrastructure.fake
return Context.FirstOrDefault(e => e.Id == entity.Id); return Context.FirstOrDefault(e => e.Id == entity.Id);
} }
}
} }

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

@ -1,8 +1,8 @@
using espacecollab.backend.infrastructure.sql.dtos; using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.interfaces namespace espacecollab.backend.infrastructure.interfaces;
public interface IBusinessUnitRepository : IGenericRepository<BusinessUnitSqlDto>
{ {
public interface IBusinessUnitRepository : IGenericRepository<BusinessUnitSqlDto> public IList<BusinessUnitSqlDto> GetBusinessUnitsByAgence(int agenceId);
{
}
} }

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

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

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

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

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

@ -1,10 +1,9 @@
using espacecollab.backend.infrastructure.sql.dtos; using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.interfaces namespace espacecollab.backend.infrastructure.interfaces;
public interface IReferencementRepository : IGenericRepository<ReferencementSqlDto>
{ {
public interface IReferencementRepository : IGenericRepository<ReferencementSqlDto>
{
IList<CollaborateurSqlDto>? GetReferrersByCollaborateurId(int collaborateurId); IList<CollaborateurSqlDto>? GetReferrersByCollaborateurId(int collaborateurId);
IList<CollaborateurSqlDto>? GetReferrersByCollaborateurApsideMail(string apsideMail); IList<CollaborateurSqlDto>? GetReferrersByCollaborateurApsideMail(string apsideMail);
}
} }

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

@ -1,10 +1,10 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces; using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos namespace espacecollab.backend.infrastructure.sql.dtos;
public class AgenceSqlDto : IGenericIdSqlDto
{ {
public class AgenceSqlDto : IGenericIdSqlDto
{
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
@ -19,6 +19,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
Id = id; Id = id;
Name = name; Name = name;
} }
}
} }

@ -1,10 +1,10 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces; using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos namespace espacecollab.backend.infrastructure.sql.dtos;
public class BusinessUnitSqlDto : IGenericIdSqlDto
{ {
public class BusinessUnitSqlDto : IGenericIdSqlDto
{
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public int AgenceId { get; set; } public int AgenceId { get; set; }
@ -21,7 +21,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
Name = name; Name = name;
AgenceId = agenceId; AgenceId = agenceId;
} }
}
} }

@ -1,9 +1,9 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
namespace espacecollab.backend.infrastructure.sql.dtos namespace espacecollab.backend.infrastructure.sql.dtos;
public class CollaborateurAppartientBusinessUnitSqlDto
{ {
public class CollaborateurAppartientBusinessUnitSqlDto
{
public int CollaborateurId { get; set; } public int CollaborateurId { get; set; }
public int BusinessUnitId { get; set; } public int BusinessUnitId { get; set; }
@ -18,7 +18,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
CollaborateurId = collaborateurId; CollaborateurId = collaborateurId;
BusinessUnitId = businessUnitId; BusinessUnitId = businessUnitId;
} }
}
} }

@ -1,9 +1,9 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
namespace espacecollab.backend.infrastructure.sql.dtos namespace espacecollab.backend.infrastructure.sql.dtos;
public class CollaborateurCollaboreProjetSqlDto
{ {
public class CollaborateurCollaboreProjetSqlDto
{
public int CollaborateurId { get; set; } public int CollaborateurId { get; set; }
public int ProjetId { get; set; } public int ProjetId { get; set; }
public bool IsManager { get; set; } public bool IsManager { get; set; }
@ -19,6 +19,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
ProjetId = projetId; ProjetId = projetId;
IsManager = isManager; IsManager = isManager;
} }
}
} }

@ -1,9 +1,9 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
namespace espacecollab.backend.infrastructure.sql.dtos namespace espacecollab.backend.infrastructure.sql.dtos;
public class CollaborateurEstFonctionSqlDto
{ {
public class CollaborateurEstFonctionSqlDto
{
public int CollaborateurId { get; set; } public int CollaborateurId { get; set; }
public int FonctionId { get; set; } public int FonctionId { get; set; }
@ -17,7 +17,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
CollaborateurId = collaborateurId; CollaborateurId = collaborateurId;
FonctionId = fonctionId; FonctionId = fonctionId;
} }
}
} }

@ -3,10 +3,10 @@ using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces; using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace espacecollab.backend.infrastructure.sql.dtos namespace espacecollab.backend.infrastructure.sql.dtos;
public class CollaborateurSqlDto : IGenericIdSqlDto
{ {
public class CollaborateurSqlDto : IGenericIdSqlDto
{
[Key] [Key]
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
@ -51,6 +51,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
ReferrerId = referrerId; ReferrerId = referrerId;
BusinessUnitId = businessUnitId; BusinessUnitId = businessUnitId;
} }
}
} }

@ -6,17 +6,17 @@ namespace espacecollab.backend.infrastructure.sql.dtos
public class FonctionSqlDto : IGenericIdSqlDto public class FonctionSqlDto : IGenericIdSqlDto
{ {
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Intitule { get; set; }
[ExcludeFromCodeCoverage] [ExcludeFromCodeCoverage]
private FonctionSqlDto() private FonctionSqlDto()
{ {
} }
public FonctionSqlDto(int id, string name) public FonctionSqlDto(int id, string intitule)
{ {
Id = id; Id = id;
Name = name; Intitule = intitule;
} }

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

@ -2,10 +2,10 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces; using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos namespace espacecollab.backend.infrastructure.sql.dtos;
public class PeriodeEssaiSqlDto : IGenericIdSqlDto
{ {
public class PeriodeEssaiSqlDto : IGenericIdSqlDto
{
public int Id { get; set; } public int Id { get; set; }
public DateTime StartingDate { get; set; } public DateTime StartingDate { get; set; }
public DateTime PlannedEndingDate { get; set; } public DateTime PlannedEndingDate { get; set; }
@ -30,5 +30,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
Issue = issue; Issue = issue;
CollaborateurId = collaborateurId; CollaborateurId = collaborateurId;
} }
}
} }

@ -1,10 +1,10 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces; using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos namespace espacecollab.backend.infrastructure.sql.dtos;
public class ProjetSqlDto : IGenericIdSqlDto
{ {
public class ProjetSqlDto : IGenericIdSqlDto
{
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Client { get; set; } public string Client { get; set; }
@ -26,5 +26,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
StartingDate = startingDate; StartingDate = startingDate;
EndingDate = endingDate; EndingDate = endingDate;
} }
}
} }

@ -1,9 +1,9 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
namespace espacecollab.backend.infrastructure.sql.dtos namespace espacecollab.backend.infrastructure.sql.dtos;
public class ProjetUtiliseTechnologieSqlDto
{ {
public class ProjetUtiliseTechnologieSqlDto
{
public int ProjetId { get; set; } public int ProjetId { get; set; }
public int TechnologieId { get; set; } public int TechnologieId { get; set; }
@ -17,5 +17,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
ProjetId = projetId; ProjetId = projetId;
TechnologieId = technologieId; TechnologieId = technologieId;
} }
}
} }

@ -1,10 +1,10 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces; using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos namespace espacecollab.backend.infrastructure.sql.dtos;
public class ReferencementSqlDto : IGenericIdSqlDto
{ {
public class ReferencementSqlDto : IGenericIdSqlDto
{
public int Id { get; set; } public int Id { get; set; }
public DateTime StartingDate { get; set; } public DateTime StartingDate { get; set; }
public DateTime EndingDate { get; set; } public DateTime EndingDate { get; set; }
@ -24,5 +24,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
ReferredId = referredId; ReferredId = referredId;
ReferrerId = referrerId; ReferrerId = referrerId;
} }
}
} }

@ -1,9 +1,9 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
namespace espacecollab.backend.infrastructure.sql.dtos namespace espacecollab.backend.infrastructure.sql.dtos;
public class SiteDeveloppeProjetSqlDto
{ {
public class SiteDeveloppeProjetSqlDto
{
public int SiteId { get; set; } public int SiteId { get; set; }
public int ProjetId { get; set; } public int ProjetId { get; set; }
@ -17,8 +17,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
SiteId = siteId; SiteId = siteId;
ProjetId = projetId; ProjetId = projetId;
} }
}
} }

@ -1,10 +1,10 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces; using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos namespace espacecollab.backend.infrastructure.sql.dtos;
public class SiteSqlDto : IGenericIdSqlDto
{ {
public class SiteSqlDto : IGenericIdSqlDto
{
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Address { get; set; } public string Address { get; set; }
@ -22,8 +22,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
Address = address; Address = address;
BusinessUnitId = businessUnitId; BusinessUnitId = businessUnitId;
} }
}
} }

@ -1,10 +1,10 @@
using System.Diagnostics.CodeAnalysis; using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces; using System.Diagnostics.CodeAnalysis;
namespace espacecollab.backend.infrastructure.sql.dtos namespace espacecollab.backend.infrastructure.sql.dtos;
public class TechnologieSqlDto : IGenericIdSqlDto
{ {
public class TechnologieSqlDto : IGenericIdSqlDto
{
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
@ -18,6 +18,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
Id = id; Id = id;
Name = name; Name = name;
} }
}
} }

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

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

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

@ -2,13 +2,12 @@
using espacecollab.backend.infrastructure.sql.Options; using espacecollab.backend.infrastructure.sql.Options;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
namespace espacecollab.backend.infrastructure.sql
namespace espacecollab.backend.infrastructure.sql;
public class MainDbContext : DbContext
{ {
public class MainDbContext : DbContext
{
private IOptions<SqlOption> SqlSettings { get; } private IOptions<SqlOption> SqlSettings { get; }
private DbSet<CollaborateurSqlDto>? Collaborateur { get; set; }
private DbSet<AgenceSqlDto>? Agence { get; set; }
public MainDbContext(IOptions<SqlOption> sqlSettings) public MainDbContext(IOptions<SqlOption> sqlSettings)
{ {
@ -24,16 +23,20 @@ namespace espacecollab.backend.infrastructure.sql
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {
modelBuilder.Entity<BusinessUnitSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder.Entity<AgenceSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn(); modelBuilder.Entity<AgenceSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder.Entity<CollaborateurSqlDto>().Property(p=> p.Id).UseMySqlIdentityColumn(); modelBuilder.Entity<FonctionSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder.Entity<TechnologieSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder.Entity<CollaborateurSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder modelBuilder
.Entity<CollaborateurSqlDto>() .Entity<CollaborateurSqlDto>()
.Property(e => e.Gender) .Property(e => e.Gender)
.HasConversion<string>(); .HasConversion<string>();
modelBuilder modelBuilder
.Entity<CollaborateurSqlDto>() .Entity<CollaborateurSqlDto>()
.Property(e => e.Status) .Property(e => e.Status)
.HasConversion<string>(); .HasConversion<string>();
} }
}
} }

@ -1,7 +1,7 @@
namespace espacecollab.backend.infrastructure.sql.Options namespace espacecollab.backend.infrastructure.sql.Options;
public class SqlOption
{ {
public class SqlOption
{
public static string Key => "Sql"; public static string Key => "Sql";
public bool LoadFake { get; set; } public bool LoadFake { get; set; }
public string ConnectionString { get; set; } public string ConnectionString { get; set; }
@ -10,5 +10,4 @@
{ {
ConnectionString = string.Empty; 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 BusinessUnitSqlRepository : GenericSqlRepository<BusinessUnitSqlDto>, IBusinessUnitRepository
{
public BusinessUnitSqlRepository(MainDbContext context) : base(context)
{
}
public IList<BusinessUnitSqlDto> GetBusinessUnitsByAgence(int agenceId)
=> Context.Set<BusinessUnitSqlDto>().Where(bu => bu.AgenceId == agenceId).ToList();
}

@ -1,10 +1,10 @@
using espacecollab.backend.infrastructure.interfaces; using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos; using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.sql.Repository namespace espacecollab.backend.infrastructure.sql.Repository;
public class CollaborateurSqlRepository : GenericSqlRepository<CollaborateurSqlDto>, ICollaborateurRepository
{ {
public class CollaborateurSqlRepository : GenericSqlRepository<CollaborateurSqlDto>, ICollaborateurRepository
{
public CollaborateurSqlRepository(MainDbContext context) : base(context) public CollaborateurSqlRepository(MainDbContext context) : base(context)
{ {
Context = context; Context = context;
@ -18,5 +18,4 @@ namespace espacecollab.backend.infrastructure.sql.Repository
public CollaborateurSqlDto? GetCollaborateurByApsideMail(string apsideMail) public CollaborateurSqlDto? GetCollaborateurByApsideMail(string apsideMail)
=> Context?.Set<CollaborateurSqlDto>().SingleOrDefault(collaborateur => collaborateur.ApsideMail == 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)
{
}
}

@ -1,11 +1,10 @@
using espacecollab.backend.infrastructure.interfaces; using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces; using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
using Microsoft.EntityFrameworkCore;
namespace espacecollab.backend.infrastructure.sql.Repository namespace espacecollab.backend.infrastructure.sql.Repository;
public class GenericSqlRepository<T> : IGenericRepository<T> where T : class, IGenericIdSqlDto
{ {
public class GenericSqlRepository<T> : IGenericRepository<T> where T : class, IGenericIdSqlDto
{
protected MainDbContext Context { get; set; } protected MainDbContext Context { get; set; }
public GenericSqlRepository(MainDbContext context) public GenericSqlRepository(MainDbContext context)
@ -17,14 +16,16 @@ namespace espacecollab.backend.infrastructure.sql.Repository
{ {
Context.Set<T>().Add(entity); Context.Set<T>().Add(entity);
Context.SaveChanges(); Context.SaveChanges();
return entity;
return entity;
} }
public virtual bool Delete(int entityId) public virtual bool Delete(int entityId)
{ {
T? entity = GetById(entityId); T? entity = GetById(entityId);
if (entity == null) return false; if (entity == null)
return false;
Context.Set<T>().Remove(entity); Context.Set<T>().Remove(entity);
return Context.SaveChanges() == 1; return Context.SaveChanges() == 1;
@ -37,14 +38,14 @@ namespace espacecollab.backend.infrastructure.sql.Repository
public virtual T? GetById(int id) public virtual T? GetById(int id)
{ {
return Context.Set<T>().FirstOrDefault(entity => entity.Id == id); return Context.Set<T>().SingleOrDefault(entity => entity.Id == id);
} }
public virtual T? Update(T entity) public virtual T? Update(T entity)
{ {
Context.Set<T>().Update(entity); Context.Set<T>().Update(entity);
Context.SaveChanges(); Context.SaveChanges();
return Context.Set<T>().FirstOrDefault(e => e.Id == entity.Id);
} 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 TechnologieSqlRepository : GenericSqlRepository<TechnologieSqlDto>, ITechnologieRepository
{
public TechnologieSqlRepository(MainDbContext context) : base(context)
{
}
}

@ -23,7 +23,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.infras
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.infrastructure.fake", "espacecollab.backend.infrastructure.fake\espacecollab.backend.infrastructure.fake.csproj", "{48253B9B-9B42-48CF-A95F-358171BABA74}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.infrastructure.fake", "espacecollab.backend.infrastructure.fake\espacecollab.backend.infrastructure.fake.csproj", "{48253B9B-9B42-48CF-A95F-358171BABA74}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "espacecollab.backend.appservices.interfaces", "espacecollab.backend.appservices.interfaces\espacecollab.backend.appservices.interfaces.csproj", "{7872657E-46E2-44A1-AFA6-0D3B9E45084A}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.appservices.interfaces", "espacecollab.backend.appservices.interfaces\espacecollab.backend.appservices.interfaces.csproj", "{7872657E-46E2-44A1-AFA6-0D3B9E45084A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "espacecollab.backend.api.tests", "espacecollab.backend.api.tests\espacecollab.backend.api.tests.csproj", "{5EA7CAB6-B7A8-4A54-8A1D-774A376974CB}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -63,6 +65,10 @@ Global
{7872657E-46E2-44A1-AFA6-0D3B9E45084A}.Debug|Any CPU.Build.0 = Debug|Any CPU {7872657E-46E2-44A1-AFA6-0D3B9E45084A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7872657E-46E2-44A1-AFA6-0D3B9E45084A}.Release|Any CPU.ActiveCfg = Release|Any CPU {7872657E-46E2-44A1-AFA6-0D3B9E45084A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7872657E-46E2-44A1-AFA6-0D3B9E45084A}.Release|Any CPU.Build.0 = Release|Any CPU {7872657E-46E2-44A1-AFA6-0D3B9E45084A}.Release|Any CPU.Build.0 = Release|Any CPU
{5EA7CAB6-B7A8-4A54-8A1D-774A376974CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5EA7CAB6-B7A8-4A54-8A1D-774A376974CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5EA7CAB6-B7A8-4A54-8A1D-774A376974CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5EA7CAB6-B7A8-4A54-8A1D-774A376974CB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -76,6 +82,7 @@ Global
{3E9E4801-D686-4581-8051-E0E1B036AC70} = {E29F5CA9-ABAF-4437-8633-49FF27110E6D} {3E9E4801-D686-4581-8051-E0E1B036AC70} = {E29F5CA9-ABAF-4437-8633-49FF27110E6D}
{48253B9B-9B42-48CF-A95F-358171BABA74} = {E29F5CA9-ABAF-4437-8633-49FF27110E6D} {48253B9B-9B42-48CF-A95F-358171BABA74} = {E29F5CA9-ABAF-4437-8633-49FF27110E6D}
{7872657E-46E2-44A1-AFA6-0D3B9E45084A} = {CE5199B3-E423-46C1-B141-18C46473D964} {7872657E-46E2-44A1-AFA6-0D3B9E45084A} = {CE5199B3-E423-46C1-B141-18C46473D964}
{5EA7CAB6-B7A8-4A54-8A1D-774A376974CB} = {19237F76-6CA9-47DF-87F8-8027C78070C9}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0A56A44C-135E-4CE4-834B-8DFDF69DC415} SolutionGuid = {0A56A44C-135E-4CE4-834B-8DFDF69DC415}

Loading…
Cancel
Save