MR creationDtoSql vers develop #2

Merged
AlexandreRuiz merged 20 commits from creationDtoSql into develop 3 years ago
  1. 2
      .gitignore
  2. 12
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/AgenceController.cs
  3. 68
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/BaseController.cs
  4. 48
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/CollaborateursController.cs
  5. 38
      Collaborateur_Epa_Back/espacecollab.backend.api/Program.cs
  6. 29
      Collaborateur_Epa_Back/espacecollab.backend.api/Register.cs
  7. 52
      Collaborateur_Epa_Back/espacecollab.backend.api/Startup.cs
  8. 6
      Collaborateur_Epa_Back/espacecollab.backend.api/appsettings.json
  9. 4
      Collaborateur_Epa_Back/espacecollab.backend.api/espacecollab.backend.api.csproj
  10. 8
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/AgenceApiDto.cs
  11. 10
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/CollaborateurApiDto.cs
  12. 9
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/EnumGenreApi.cs
  13. 10
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/EnumStatutApi.cs
  14. 7
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Interfaces/IGenericIdSqlDto.cs
  15. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/AgenceMapper.cs
  16. 23
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/CollaborateurApiDtoMapper.cs
  17. 29
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/EnumGenreMapper.cs
  18. 31
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/EnumStatutMapper.cs
  19. 6
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/espacecollab.backend.appservices.dtos.csproj
  20. 17
      Collaborateur_Epa_Back/espacecollab.backend.appservices.interfaces/IGenericsServices.cs
  21. 14
      Collaborateur_Epa_Back/espacecollab.backend.appservices.interfaces/espacecollab.backend.appservices.interfaces.csproj
  22. 14
      Collaborateur_Epa_Back/espacecollab.backend.appservices/AgenceService.cs
  23. 36
      Collaborateur_Epa_Back/espacecollab.backend.appservices/CollaborateursServices.cs
  24. 68
      Collaborateur_Epa_Back/espacecollab.backend.appservices/GenericsServices.cs
  25. 6
      Collaborateur_Epa_Back/espacecollab.backend.appservices/espacecollab.backend.appservices.csproj
  26. 18
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeAgenceRepository.cs
  27. 42
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeCollaborateurRepository.cs
  28. 49
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/GenericFakeRepository.cs
  29. 14
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/espacecollab.backend.infrastructure.fake.csproj
  30. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IAgenceRepository.cs
  31. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IBusinessUnitRepository.cs
  32. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/ICollaborateurRepository.cs
  33. 14
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IGenericRepository.cs
  34. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IPeriodeEssaiRepository.cs
  35. 9
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IProjetRepository.cs
  36. 10
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IReferencementRepository.cs
  37. 13
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/espacecollab.backend.infrastructure.interfaces.csproj
  38. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/AgenceSqlDto.cs
  39. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/BusinessUnitSqlDto.cs
  40. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurAppartientBusinessUnitSqlDto.cs
  41. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurCollaboreProjetSqlDto.cs
  42. 21
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurEffectuePeriodeEssaiSqlDto.cs
  43. 10
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurEstFonctionSqlDto.cs
  44. 24
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurSqlDto.cs
  45. 9
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/EnumGenre.cs
  46. 10
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/EnumStatut.cs
  47. 9
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/FonctionSqlDto.cs
  48. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Interfaces/IGenericIdSqlDto.cs
  49. 15
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/PeriodeEssaiSqlDto.cs
  50. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/ProjetSqlDto.cs
  51. 6
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/ProjetUtiliseTechnologieSqlDto.cs
  52. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/ReferencementSqlDto.cs
  53. 9
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/SiteDeveloppeProjetSqlDto.cs
  54. 12
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/SiteSqlDto.cs
  55. 12
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/TechnologieSqlDto.cs
  56. 9
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Values/EnumGenreSql.cs
  57. 4
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Values/EnumIssueSql.cs
  58. 10
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Values/EnumStatutSql.cs
  59. 23
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/MainDbContext.cs
  60. 14
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Options/SqlOption.cs
  61. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/AgenceSqlRepository.cs
  62. 22
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/CollaborateurSqlRepository.cs
  63. 47
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/GenericSqlRepository.cs
  64. 28
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/db/db_1_0_0.sql
  65. 17
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/espacecollab.backend.infrastructure.sql.csproj
  66. 44
      Collaborateur_Epa_Back/espacecollab.backend.sln

2
.gitignore vendored

@ -387,4 +387,6 @@ FodyWeavers.xsd
.idea/
*.sln.iml
appsettings.Development.json
*.Development
*.Development.json

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

@ -0,0 +1,68 @@
using espacecollab.backend.appservices.dtos.Interfaces;
using espacecollab.backend.appservices.interfaces;
using Microsoft.AspNetCore.Mvc;
namespace espacecollab.backend.api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public abstract class BaseController<TO> : Controller 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 ActionResult<TO> Add(TO apiDto)
{
TO? addedApiDto = Services.Add(apiDto);
if (addedApiDto == null)
return Problem();
return Ok(addedApiDto);
}
[HttpDelete("{id:int:min(1)}")]
public ActionResult Delete(uint id)
{
bool isDeleted = Services.Delete(id);
if (!isDeleted)
return Problem();
return Ok();
}
[HttpPut("{collaborateurId:int:min(1)}")]
public ActionResult<TO> Update(uint id, TO apiDto)
{
if (apiDto.Id != id)
return Unauthorized();
TO? updatedApiDto = Services.Update(apiDto);
if (updatedApiDto == null)
return Problem();
return Ok(updatedApiDto);
}
}
}

@ -0,0 +1,48 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
using Microsoft.AspNetCore.Mvc;
namespace espacecollab.backend.api.Controllers
{
//[Route("api/[controller]")]
//[ApiController]
public class CollaborateursController : BaseController<CollaborateurApiDto>
{
private CollaborateursServices CollaborateursServices { get; }
public CollaborateursController(CollaborateursServices collaborateursServices) : base(collaborateursServices)
{
CollaborateursServices = collaborateursServices;
}
[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("referrer/{referrerId:int:min(1)}")]
public ActionResult<IEnumerable<CollaborateurApiDto>> GetCollaborateursByReferrer(uint referrerId)
{
IEnumerable<CollaborateurApiDto> collaborateurs = CollaborateursServices.GetCollaborateursByReferrer(referrerId);
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,25 +1,17 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
namespace espacecollab.backend.api
{
app.UseSwagger();
app.UseSwaggerUI();
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>();
});
}
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

@ -0,0 +1,29 @@
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.AddScoped<CollaborateursServices>();
services.AddScoped<AgenceService>();
if (contextOptions.LoadFake)
{
services.AddSingleton<ICollaborateurRepository, FakeCollaborateurRepository>();
services.AddSingleton<IAgenceRepository, FakeAgenceRepository>();
}
else
{
services.AddScoped<MainDbContext>();
services.AddScoped<ICollaborateurRepository, CollaborateurSqlRepository>();
services.AddScoped<IAgenceRepository, AgenceSqlRepository>();
}
}
}

@ -0,0 +1,52 @@
using espacecollab.backend.infrastructure.sql.Options;
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();
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.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

@ -5,5 +5,9 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"Sql": {
"LoadFake": true,
"ConnectionString": "server=127.0.0.1;uid=root;pwd=root;database=collaborateur_epa"
}
}

@ -11,7 +11,9 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
<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>
</Project>

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

@ -0,0 +1,10 @@
using espacecollab.backend.appservices.dtos.Interfaces;
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 uint Id { get; set; } = Id;
}
}

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

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

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

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

@ -0,0 +1,23 @@
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(), collaborateurSql.ChildrenNumber,
collaborateurSql.Address, collaborateurSql.Telephone, collaborateurSql.PersonalMail, collaborateurSql.ApsideMail,
collaborateurSql.ResignationDate, collaborateurSql.ReferrerId, 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(), collaborateurApi.ChildrenNumber,
collaborateurApi.Address, collaborateurApi.Telephone, collaborateurApi.PersonalMail, collaborateurApi.ApsideMail,
collaborateurApi.ResignationDate, collaborateurApi.ReferrerId, collaborateurApi.BusinessUnitId);
}
}
}

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

@ -0,0 +1,31 @@
using espacecollab.backend.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,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
@ -6,4 +6,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\espacecollab.backend.infrastructure.sql.dtos\espacecollab.backend.infrastructure.sql.dtos.csproj" />
</ItemGroup>
</Project>

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

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

@ -0,0 +1,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 AgenceService : GenericsServices<AgenceSqlDto, AgenceApiDto>
{
public AgenceService(IAgenceRepository agenceRepository)
:base(agenceRepository, AgenceMapper.ToApi, AgenceMapper.ToSql)
{
}
}

@ -0,0 +1,36 @@
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,68 @@
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 TO? Add(TO apiDto)
{
T sqlDto = MapperToSqlDto(apiDto);
T? entitySqlValidation = GenericRepository.Add(sqlDto);
if (entitySqlValidation == null)
return null;
return MapperToApiDto(entitySqlValidation);
}
public 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);
}
}
}

@ -6,4 +6,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\espacecollab.backend.appservices.dtos\espacecollab.backend.appservices.dtos.csproj" />
<ProjectReference Include="..\espacecollab.backend.appservices.interfaces\espacecollab.backend.appservices.interfaces.csproj" />
<ProjectReference Include="..\espacecollab.backend.infrastructure.sql\espacecollab.backend.infrastructure.sql.csproj" />
</ItemGroup>
</Project>

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

@ -0,0 +1,42 @@
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), 2, 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, 1)
};
}
#region méthodes spécifiques à l'interface ICollaborateurRepository
public IList<CollaborateurSqlDto> GetCollaborateursByBusinessUnit(int businessUnitId)
{
return Context.Where(entity => entity.BusinessUnitId == businessUnitId).ToList();
}
public IList<CollaborateurSqlDto> GetCollaborateursByReferrer(int referrerId)
{
return Context.Where(entity => entity.ReferrerId == referrerId).ToList();
}
public CollaborateurSqlDto GetCollaborateurByApsideMail(string apsideMail)
{
return Context.First(entity => entity.ApsideMail == apsideMail);
}
#endregion
}
}

@ -0,0 +1,49 @@
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; }
public virtual T? Add(T entity)
{
int lastId = Context.Max(e => e.Id);
entity.Id = lastId + 1;
Context.Add(entity);
return entity;
}
public virtual bool Delete(int entityId)
{
T? entity = GetById(entityId);
if (entity == null) return false;
return Context.Remove(entity);
}
public virtual IEnumerable<T> GetAll()
{
return Context.ToList();
}
public virtual T? GetById(int id)
{
return Context.FirstOrDefault(entity => entity.Id == id);
}
public virtual T? Update(T entity)
{
T? oldEntity = GetById(entity.Id);
if (oldEntity == null)
return null;
Context.Remove(oldEntity);
Context.Add(entity);
return Context.FirstOrDefault(e => e.Id == entity.Id);
}
}
}

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

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

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

@ -0,0 +1,11 @@
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);
IList<CollaborateurSqlDto> GetCollaborateursByReferrer(int referrerId);
}
}

@ -0,0 +1,14 @@
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);
//void GetAll<T>() where T : class, IGenericSqlDto;
}
}

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

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

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

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

@ -1,10 +1,11 @@
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos
{
public class AgenceSqlDto
public class AgenceSqlDto : IGenericIdSqlDto
{
public Guid Id { get; set; }
public int Id { get; set; }
public string Name { get; set; }
[ExcludeFromCodeCoverage]
@ -13,10 +14,11 @@ namespace espacecollab.backend.infrastructure.sql.dtos
{
}
public AgenceSqlDto(Guid id, string name)
public AgenceSqlDto(int id, string name)
{
Id = id;
Name = name;
}
}
}

@ -1,12 +1,13 @@
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos
{
public class BusinessUnitSqlDto
public class BusinessUnitSqlDto : IGenericIdSqlDto
{
public Guid Id { get; set; }
public int Id { get; set; }
public string Name { get; set; }
public Guid AgenceId { get; set; }
public int AgenceId { get; set; }
[ExcludeFromCodeCoverage]
@ -14,11 +15,13 @@ namespace espacecollab.backend.infrastructure.sql.dtos
{
}
public BusinessUnitSqlDto(Guid id, string name, Guid agenceId)
public BusinessUnitSqlDto(int id, string name, int agenceId)
{
Id = id;
Name = name;
AgenceId = agenceId;
}
}
}

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

@ -4,8 +4,8 @@ namespace espacecollab.backend.infrastructure.sql.dtos
{
public class CollaborateurCollaboreProjetSqlDto
{
public Guid CollaborateurId { get; set; }
public Guid ProjetId { get; set; }
public int CollaborateurId { get; set; }
public int ProjetId { get; set; }
public bool IsManager { get; set; }
[ExcludeFromCodeCoverage]
@ -13,11 +13,12 @@ namespace espacecollab.backend.infrastructure.sql.dtos
{
}
public CollaborateurCollaboreProjetSqlDto(Guid collaborateurId, Guid projetId, bool isManager)
public CollaborateurCollaboreProjetSqlDto(int collaborateurId, int projetId, bool isManager)
{
CollaborateurId = collaborateurId;
ProjetId = projetId;
IsManager = isManager;
}
}
}

@ -1,21 +0,0 @@
using System.Diagnostics.CodeAnalysis;
namespace espacecollab.backend.infrastructure.sql.dtos.Associations
{
public class CollaborateurEffectuePeriodeEssaiSqlDto
{
public Guid CollaborateurId { get; set; }
public Guid PeriodeEssaiId { get; set;}
[ExcludeFromCodeCoverage]
private CollaborateurEffectuePeriodeEssaiSqlDto()
{
}
public CollaborateurEffectuePeriodeEssaiSqlDto(Guid collaborateurId, Guid periodeEssaiId)
{
CollaborateurId = collaborateurId;
PeriodeEssaiId = periodeEssaiId;
}
}
}

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

@ -1,30 +1,38 @@
using espacecollab.backend.infrastructure.sql.dtos.Enums;
using espacecollab.backend.infrastructure.sql.dtos.Values;
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos
{
public class CollaborateurSqlDto
public class CollaborateurSqlDto : IGenericIdSqlDto
{
public Guid Id { get; set; }
public int Id { get; set; }
public string Name { get; set; }
public string FirstName { get; set; }
public DateTime BirthDate { get; set; }
public EnumGenre Gender { get; set; }
public EnumStatut Status { 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 Guid ReferrerId { get; set; }
public int ReferrerId { 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(Guid id, string name, string firstName, DateTime birthDate, EnumGenre gender, EnumStatut status, int childrenNumber, string address, string telephone, string personalMail, string apsideMail, DateTime resignationDate, Guid referrerId)
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 referrerId, int businessUnitId)
{
Id = id;
Name = name;
@ -39,6 +47,8 @@ namespace espacecollab.backend.infrastructure.sql.dtos
ApsideMail = apsideMail;
ResignationDate = resignationDate;
ReferrerId = referrerId;
BusinessUnitId = businessUnitId;
}
}
}

@ -1,9 +0,0 @@
namespace espacecollab.backend.infrastructure.sql.dtos.Enums
{
public enum EnumGenre
{
MASCULIN,
FEMININ,
AUTRE
}
}

@ -1,10 +0,0 @@
namespace espacecollab.backend.infrastructure.sql.dtos.Enums
{
public enum EnumStatut
{
CADRE,
NONCADRE,
ALTERNANT,
STAGIAIRE
}
}

@ -1,10 +1,11 @@
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos
{
public class FonctionSqlDto
public class FonctionSqlDto : IGenericIdSqlDto
{
public Guid Id { get; set; }
public int Id { get; set; }
public string Name { get; set; }
[ExcludeFromCodeCoverage]
@ -12,10 +13,12 @@ namespace espacecollab.backend.infrastructure.sql.dtos
{
}
public FonctionSqlDto(Guid id, string name)
public FonctionSqlDto(int id, string name)
{
Id = id;
Name = name;
}
}
}

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

@ -1,22 +1,26 @@
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Values;
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos
{
public class PeriodeEssaiSqlDto
public class PeriodeEssaiSqlDto : IGenericIdSqlDto
{
public Guid Id { get; set; }
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 EnumIssue Issue { get; set; }
public EnumIssueSql Issue { get; set; }
public int CollaborateurId { get; set; }
[ExcludeFromCodeCoverage]
private PeriodeEssaiSqlDto()
{
Comment = string.Empty;
}
public PeriodeEssaiSqlDto(Guid id, DateTime startingDate, DateTime plannedEndingDate, DateTime realEndingDate, string comment, EnumIssue issue)
public PeriodeEssaiSqlDto(int id, DateTime startingDate, DateTime plannedEndingDate, DateTime realEndingDate, string comment, EnumIssueSql issue, int collaborateurId)
{
Id = id;
StartingDate = startingDate;
@ -24,6 +28,7 @@ namespace espacecollab.backend.infrastructure.sql.dtos
RealEndingDate = realEndingDate;
Comment = comment;
Issue = issue;
CollaborateurId = collaborateurId;
}
}
}

@ -1,10 +1,11 @@
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos
{
public class ProjetSqlDto
public class ProjetSqlDto : IGenericIdSqlDto
{
public Guid Id { get; set; }
public int Id { get; set; }
public string Name { get; set; }
public string Client { get; set; }
public string Description { get; set; }
@ -16,7 +17,7 @@ namespace espacecollab.backend.infrastructure.sql.dtos
{
}
public ProjetSqlDto(Guid id, string name, string client, string description, DateTime startingDate, DateTime endingDate)
public ProjetSqlDto(int id, string name, string client, string description, DateTime startingDate, DateTime endingDate)
{
Id = id;
Name = name;

@ -4,15 +4,15 @@ namespace espacecollab.backend.infrastructure.sql.dtos
{
public class ProjetUtiliseTechnologieSqlDto
{
public Guid ProjetId { get; set; }
public Guid TechnologieId { get; set; }
public int ProjetId { get; set; }
public int TechnologieId { get; set; }
[ExcludeFromCodeCoverage]
private ProjetUtiliseTechnologieSqlDto()
{
}
public ProjetUtiliseTechnologieSqlDto(Guid projetId, Guid technologieId)
public ProjetUtiliseTechnologieSqlDto(int projetId, int technologieId)
{
ProjetId = projetId;
TechnologieId = technologieId;

@ -1,21 +1,22 @@
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos
{
public class ReferencementSqlDto
public class ReferencementSqlDto : IGenericIdSqlDto
{
public Guid Id { get; set; }
public int Id { get; set; }
public DateTime StartingDate { get; set; }
public DateTime EndingDate { get; set; }
public Guid ReferredId { get; set; }
public Guid ReferrerId { get; set; }
public int ReferredId { get; set; }
public int ReferrerId { get; set; }
[ExcludeFromCodeCoverage]
private ReferencementSqlDto()
{
}
public ReferencementSqlDto(Guid id, DateTime startingDate, DateTime endingDate, Guid referredId, Guid referrerId)
public ReferencementSqlDto(int id, DateTime startingDate, DateTime endingDate, int referredId, int referrerId)
{
Id = id;
StartingDate = startingDate;

@ -4,18 +4,21 @@ namespace espacecollab.backend.infrastructure.sql.dtos
{
public class SiteDeveloppeProjetSqlDto
{
public Guid SiteId { get; set; }
public Guid ProjetId { get; set; }
public int SiteId { get; set; }
public int ProjetId { get; set; }
[ExcludeFromCodeCoverage]
private SiteDeveloppeProjetSqlDto()
{
}
public SiteDeveloppeProjetSqlDto(Guid siteId, Guid projetId)
public SiteDeveloppeProjetSqlDto(int siteId, int projetId)
{
SiteId = siteId;
ProjetId = projetId;
}
}
}

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

@ -1,8 +1,11 @@
namespace espacecollab.backend.infrastructure.sql.dtos
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.infrastructure.sql.dtos
{
public class TechnologieSqlDto
public class TechnologieSqlDto : IGenericIdSqlDto
{
public Guid Id { get; set; }
public int Id { get; set; }
public string Name { get; set; }
[ExcludeFromCodeCoverage]
@ -10,10 +13,11 @@
{
}
public TechnologieSqlDto(Guid id, string name)
public TechnologieSqlDto(int id, string name)
{
Id = id;
Name = name;
}
}
}

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

@ -1,6 +1,6 @@
namespace espacecollab.backend.infrastructure.sql.dtos
namespace espacecollab.backend.infrastructure.sql.dtos.Values
{
public enum EnumIssue
public enum EnumIssueSql
{
VALIDEE,
PROLONGEE_COLLAB,

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

@ -0,0 +1,23 @@
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.UseSqlServer(SqlSettings.Value.ConnectionString, builder =>
{
builder.EnableRetryOnFailure(5, TimeSpan.FromSeconds(10), null);
});
}
}
}

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

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

@ -0,0 +1,22 @@
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 IList<CollaborateurSqlDto> GetCollaborateursByReferrer(int referrerId)
=> Context.Set<CollaborateurSqlDto>().Where(collaborateur => collaborateur.ReferrerId == referrerId).ToList();
public CollaborateurSqlDto? GetCollaborateurByApsideMail(string apsideMail)
=> Context?.Set<CollaborateurSqlDto>().SingleOrDefault(collaborateur => collaborateur.ApsideMail == apsideMail);
}
}

@ -0,0 +1,47 @@
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)
{
return Context.Set<T>().Add(entity) as T;
}
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>().FirstOrDefault(entity => entity.Id == id);
}
public virtual T? Update(T entity)
{
Context.Set<T>().Update(entity);
Context.SaveChanges();
return Context.Set<T>().FirstOrDefault(e => e.Id == entity.Id);
}
}
}

@ -46,19 +46,6 @@ CREATE TABLE IF NOT EXISTS Technologie(
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,
PRIMARY KEY (Id)
);
DROP TABLE IF EXISTS Fonction;
CREATE TABLE IF NOT EXISTS Fonction(
Id int NOT NULL UNIQUE,
@ -69,7 +56,7 @@ CREATE TABLE IF NOT EXISTS Fonction(
DROP TABLE IF EXISTS Collaborateur;
CREATE TABLE IF NOT EXISTS Collaborateur(
Id int NOT NULL AUTO_INCREMENT,
Name varchar(100) NOT NULL UNIQUE,
Name varchar(100) NOT NULL,
FirstName varchar(100) NOT NULL,
BirthDate date NOT NULL,
Gender ENUM('MASCULIN','FEMININ','AUTRE') NOT NULL,
@ -85,6 +72,19 @@ CREATE TABLE IF NOT EXISTS Collaborateur(
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,

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
@ -6,4 +6,19 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MySql.EntityFrameworkCore" Version="5.0.8" />
</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>

@ -3,15 +3,27 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31912.275
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "espacecollab.backend.api", "espacecollab.backend.api\espacecollab.backend.api.csproj", "{A8DEB005-D7E2-4A96-B004-A66BBF12AC54}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.api", "espacecollab.backend.api\espacecollab.backend.api.csproj", "{A8DEB005-D7E2-4A96-B004-A66BBF12AC54}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "espacecollab.backend.appservices", "espacecollab.backend.appservices\espacecollab.backend.appservices.csproj", "{70F1BE1C-87C1-4CCF-A7E8-2A36F3F16D9E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.appservices", "espacecollab.backend.appservices\espacecollab.backend.appservices.csproj", "{70F1BE1C-87C1-4CCF-A7E8-2A36F3F16D9E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "espacecollab.backend.appservices.dtos", "espacecollab.backend.appservices.dtos\espacecollab.backend.appservices.dtos.csproj", "{CB0CB8FC-0E53-4205-AAA3-4176211C922B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.appservices.dtos", "espacecollab.backend.appservices.dtos\espacecollab.backend.appservices.dtos.csproj", "{CB0CB8FC-0E53-4205-AAA3-4176211C922B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "espacecollab.backend.infrastructure.sql", "espacecollab.backend.infrastructure.sql\espacecollab.backend.infrastructure.sql.csproj", "{590FF09D-0DF3-4881-8D86-E4FDAAC75FDC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.infrastructure.sql", "espacecollab.backend.infrastructure.sql\espacecollab.backend.infrastructure.sql.csproj", "{590FF09D-0DF3-4881-8D86-E4FDAAC75FDC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "espacecollab.backend.infrastructure.sql.dtos", "espacecollab.backend.infrastructure.sql.dtos\espacecollab.backend.infrastructure.sql.dtos.csproj", "{26C08CE0-E6E5-4E03-8AEA-233F93218A3B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.infrastructure.sql.dtos", "espacecollab.backend.infrastructure.sql.dtos\espacecollab.backend.infrastructure.sql.dtos.csproj", "{26C08CE0-E6E5-4E03-8AEA-233F93218A3B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "1 Host", "1 Host", "{19237F76-6CA9-47DF-87F8-8027C78070C9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2 ApplicationsServices", "2 ApplicationsServices", "{CE5199B3-E423-46C1-B141-18C46473D964}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4 Infrastructure", "4 Infrastructure", "{E29F5CA9-ABAF-4437-8633-49FF27110E6D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.infrastructure.interfaces", "espacecollab.backend.infrastructure.interfaces\espacecollab.backend.infrastructure.interfaces.csproj", "{3E9E4801-D686-4581-8051-E0E1B036AC70}"
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}"
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}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -39,10 +51,32 @@ Global
{26C08CE0-E6E5-4E03-8AEA-233F93218A3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26C08CE0-E6E5-4E03-8AEA-233F93218A3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26C08CE0-E6E5-4E03-8AEA-233F93218A3B}.Release|Any CPU.Build.0 = Release|Any CPU
{3E9E4801-D686-4581-8051-E0E1B036AC70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E9E4801-D686-4581-8051-E0E1B036AC70}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E9E4801-D686-4581-8051-E0E1B036AC70}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E9E4801-D686-4581-8051-E0E1B036AC70}.Release|Any CPU.Build.0 = Release|Any CPU
{48253B9B-9B42-48CF-A95F-358171BABA74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48253B9B-9B42-48CF-A95F-358171BABA74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48253B9B-9B42-48CF-A95F-358171BABA74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48253B9B-9B42-48CF-A95F-358171BABA74}.Release|Any CPU.Build.0 = Release|Any CPU
{7872657E-46E2-44A1-AFA6-0D3B9E45084A}.Debug|Any CPU.ActiveCfg = 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.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{A8DEB005-D7E2-4A96-B004-A66BBF12AC54} = {19237F76-6CA9-47DF-87F8-8027C78070C9}
{70F1BE1C-87C1-4CCF-A7E8-2A36F3F16D9E} = {CE5199B3-E423-46C1-B141-18C46473D964}
{CB0CB8FC-0E53-4205-AAA3-4176211C922B} = {CE5199B3-E423-46C1-B141-18C46473D964}
{590FF09D-0DF3-4881-8D86-E4FDAAC75FDC} = {E29F5CA9-ABAF-4437-8633-49FF27110E6D}
{26C08CE0-E6E5-4E03-8AEA-233F93218A3B} = {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}
{7872657E-46E2-44A1-AFA6-0D3B9E45084A} = {CE5199B3-E423-46C1-B141-18C46473D964}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0A56A44C-135E-4CE4-834B-8DFDF69DC415}
EndGlobalSection

Loading…
Cancel
Save