clean code ReSharper

pull/4/head
Alexandre Ruiz 3 years ago
parent f44f34fdec
commit 418b4cd972
  1. 1
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/BusinessUnitController.cs
  2. 5
      Collaborateur_Epa_Back/espacecollab.backend.api/Program.cs
  3. 2
      Collaborateur_Epa_Back/espacecollab.backend.api/Register.cs
  4. 5
      Collaborateur_Epa_Back/espacecollab.backend.api/Startup.cs
  5. 5
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/BusinessUnitApiDto.cs
  6. 5
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/CollaborateurApiDto.cs
  7. 5
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Interfaces/IGenericIdApiDto.cs
  8. 5
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/CollaborateurApiDtoMapper.cs
  9. 5
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/EnumGenreMapper.cs
  10. 5
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/EnumStatutMapper.cs
  11. 3
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/PeriodeEssaiMapper.cs
  12. 2
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/PeriodeEssaiApiDto.cs
  13. 5
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Values/EnumGenreApi.cs
  14. 5
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Values/EnumIssueApi.cs
  15. 5
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Values/EnumStatutApi.cs
  16. 5
      Collaborateur_Epa_Back/espacecollab.backend.appservices.interfaces/IGenericsServices.cs
  17. 3
      Collaborateur_Epa_Back/espacecollab.backend.appservices/BusinessUnitService.cs
  18. 5
      Collaborateur_Epa_Back/espacecollab.backend.appservices/CollaborateursService.cs
  19. 5
      Collaborateur_Epa_Back/espacecollab.backend.appservices/GenericsServices.cs
  20. 1
      Collaborateur_Epa_Back/espacecollab.backend.appservices/PeriodeEssaiService.cs
  21. 6
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeAgenceRepository.cs
  22. 6
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeBusinessUnitRepository.cs
  23. 6
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeCollaborateurRepository.cs
  24. 1
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeFonctionRepository.cs
  25. 1
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakePeriodeEssaiRepository.cs
  26. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/GenericFakeRepository.cs
  27. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IAgenceRepository.cs
  28. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IBusinessUnitRepository.cs
  29. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/ICollaborateurRepository.cs
  30. 6
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IGenericRepository.cs
  31. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IProjetRepository.cs
  32. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IReferencementRepository.cs
  33. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurAppartientBusinessUnitSqlDto.cs
  34. 6
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurCollaboreProjetSqlDto.cs
  35. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurEstFonctionSqlDto.cs
  36. 1
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/FonctionSqlDto.cs
  37. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Interfaces/IGenericIdSqlDto.cs
  38. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/ProjetSqlDto.cs
  39. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/ProjetUtiliseTechnologieSqlDto.cs
  40. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/ReferencementSqlDto.cs
  41. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/SiteDeveloppeProjetSqlDto.cs
  42. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/SiteSqlDto.cs
  43. 10
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/TechnologieSqlDto.cs
  44. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Values/EnumGenreSql.cs
  45. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Values/EnumIssueSql.cs
  46. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/Values/EnumStatutSql.cs
  47. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/MainDbContext.cs
  48. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Options/SqlOption.cs
  49. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/CollaborateurSqlRepository.cs
  50. 17
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/GenericSqlRepository.cs

@ -1,4 +1,5 @@
using espacecollab.backend.appservices; using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
using espacecollab.backend.infrastructure.sql.dtos; using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.api.Controllers namespace espacecollab.backend.api.Controllers

@ -1,5 +1,5 @@
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)
@ -14,4 +14,3 @@ namespace espacecollab.backend.api
webBuilder.UseStartup<Startup>(); webBuilder.UseStartup<Startup>();
}); });
} }
}

@ -12,7 +12,7 @@ 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<BusinessUnitService>();
services.AddScoped<FonctionService>(); services.AddScoped<FonctionService>();

@ -1,8 +1,8 @@
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; }
@ -55,4 +55,3 @@ namespace espacecollab.backend.api
}); });
} }
} }
}

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

@ -1,11 +1,10 @@
using espacecollab.backend.appservices.dtos.Interfaces; using espacecollab.backend.appservices.dtos.Interfaces;
using espacecollab.backend.appservices.dtos.Values; 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, string BirthDate, EnumGenreApi Gender, EnumStatutApi Status, int ChildrenNumber, string Address, 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 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,7 +1,6 @@
namespace espacecollab.backend.appservices.dtos.Interfaces namespace espacecollab.backend.appservices.dtos.Interfaces;
{
public interface IGenericIdApiDto public interface IGenericIdApiDto
{ {
public uint Id { get; set; } public uint Id { get; set; }
} }
}

@ -1,8 +1,8 @@
using espacecollab.backend.infrastructure.sql.dtos; using espacecollab.backend.infrastructure.sql.dtos;
using System.Globalization; 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)
@ -21,4 +21,3 @@ namespace espacecollab.backend.appservices.dtos.Mappers
DateTime.ParseExact(collaborateurApi.ResignationDate, "dd/MM/yyyy", CultureInfo.InvariantCulture), collaborateurApi.ReferrerId, collaborateurApi.BusinessUnitId); DateTime.ParseExact(collaborateurApi.ResignationDate, "dd/MM/yyyy", CultureInfo.InvariantCulture), collaborateurApi.ReferrerId, collaborateurApi.BusinessUnitId);
} }
} }
}

@ -1,8 +1,8 @@
using espacecollab.backend.appservices.dtos.Values; using espacecollab.backend.appservices.dtos.Values;
using espacecollab.backend.infrastructure.sql.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)
@ -27,4 +27,3 @@ namespace espacecollab.backend.appservices.dtos.Mappers
}; };
} }
} }
}

@ -1,8 +1,8 @@
using espacecollab.backend.appservices.dtos.Values; using espacecollab.backend.appservices.dtos.Values;
using espacecollab.backend.infrastructure.sql.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)
@ -29,4 +29,3 @@ namespace espacecollab.backend.appservices.dtos.Mappers
}; };
} }
} }
}

@ -1,4 +1,5 @@
using espacecollab.backend.infrastructure.sql.dtos; using espacecollab.backend.appservices.dtos.Values;
using espacecollab.backend.infrastructure.sql.dtos;
using espacecollab.backend.infrastructure.sql.dtos.Values; using espacecollab.backend.infrastructure.sql.dtos.Values;
namespace espacecollab.backend.appservices.dtos.Mappers; namespace espacecollab.backend.appservices.dtos.Mappers;

@ -1,5 +1,5 @@
using espacecollab.backend.appservices.dtos.Interfaces; using espacecollab.backend.appservices.dtos.Interfaces;
using espacecollab.backend.infrastructure.sql.dtos.Values; using espacecollab.backend.appservices.dtos.Values;
namespace espacecollab.backend.appservices.dtos; namespace espacecollab.backend.appservices.dtos;

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

@ -1,5 +1,5 @@
namespace espacecollab.backend.infrastructure.sql.dtos.Values namespace espacecollab.backend.appservices.dtos.Values;
{
public enum EnumIssueApi public enum EnumIssueApi
{ {
VALIDEE, VALIDEE,
@ -8,4 +8,3 @@
ARRETEE_COLLAB, ARRETEE_COLLAB,
ARRETEE_APSIDE ARRETEE_APSIDE
} }
}

@ -1,5 +1,5 @@
namespace espacecollab.backend.appservices.dtos.Values namespace espacecollab.backend.appservices.dtos.Values;
{
public enum EnumStatutApi public enum EnumStatutApi
{ {
CADRE, CADRE,
@ -7,4 +7,3 @@
ALTERNANT, ALTERNANT,
STAGIAIRE STAGIAIRE
} }
}

@ -1,7 +1,7 @@
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);
@ -14,4 +14,3 @@ namespace espacecollab.backend.appservices.interfaces
bool Delete(uint apiDtoId); bool Delete(uint apiDtoId);
} }
}

@ -1,4 +1,5 @@
using espacecollab.backend.appservices.dtos.Mappers; using espacecollab.backend.appservices.dtos;
using espacecollab.backend.appservices.dtos.Mappers;
using espacecollab.backend.infrastructure.interfaces; using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos; using espacecollab.backend.infrastructure.sql.dtos;

@ -3,8 +3,8 @@ using espacecollab.backend.appservices.dtos.Mappers;
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.appservices namespace espacecollab.backend.appservices;
{
public class CollaborateursService : GenericsServices<CollaborateurSqlDto, CollaborateurApiDto> public class CollaborateursService : GenericsServices<CollaborateurSqlDto, CollaborateurApiDto>
{ {
private ICollaborateurRepository CollaborateurRepository { get; } private ICollaborateurRepository CollaborateurRepository { get; }
@ -33,4 +33,3 @@ namespace espacecollab.backend.appservices
return CollaborateurRepository.GetCollaborateurByApsideMail(apsideMail)?.ToApi(); return CollaborateurRepository.GetCollaborateurByApsideMail(apsideMail)?.ToApi();
} }
} }
}

@ -3,8 +3,8 @@ 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
{ {
@ -64,4 +64,3 @@ namespace espacecollab.backend.appservices
return GenericRepository.Delete((int)apiDtoId); return GenericRepository.Delete((int)apiDtoId);
} }
} }
}

@ -11,5 +11,4 @@ public class PeriodeEssaiService : GenericsServices<PeriodeEssaiSqlDto, PeriodeE
: base(agenceRepository, PeriodeEssaiMapper.ToApi, PeriodeEssaiMapper.ToSql) : base(agenceRepository, PeriodeEssaiMapper.ToApi, PeriodeEssaiMapper.ToSql)
{ {
} }
} }

@ -1,8 +1,8 @@
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()
@ -10,9 +10,7 @@ namespace espacecollab.backend.infrastructure.fake
Context = new List<AgenceSqlDto> Context = new List<AgenceSqlDto>
{ {
new(1, "Tours"), new(1, "Tours"),
new(2, "Clermont-Ferrand") new(2, "Clermont-Ferrand")
}; };
} }
} }
}

@ -1,8 +1,8 @@
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 FakeBusinessUnitRepository : GenericFakeRepository<BusinessUnitSqlDto>, IBusinessUnitRepository public class FakeBusinessUnitRepository : GenericFakeRepository<BusinessUnitSqlDto>, IBusinessUnitRepository
{ {
public FakeBusinessUnitRepository() public FakeBusinessUnitRepository()
@ -10,9 +10,7 @@ namespace espacecollab.backend.infrastructure.fake
Context = new List<BusinessUnitSqlDto> Context = new List<BusinessUnitSqlDto>
{ {
new(1, "BU 1", 1), new(1, "BU 1", 1),
new(2, "BU 2", 1) new(2, "BU 2", 1)
}; };
} }
} }
}

@ -2,8 +2,8 @@
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()
@ -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)
@ -39,4 +38,3 @@ namespace espacecollab.backend.infrastructure.fake
#endregion #endregion
} }
}

@ -10,7 +10,6 @@ public class FakeFonctionRepository : GenericFakeRepository<FonctionSqlDto>, IFo
Context = new List<FonctionSqlDto> Context = new List<FonctionSqlDto>
{ {
new(1, "Fonction 1"), new(1, "Fonction 1"),
new(2, "Fonction 2") new(2, "Fonction 2")
}; };
} }

@ -11,7 +11,6 @@ public class FakePeriodeEssaiRepository : GenericFakeRepository<PeriodeEssaiSqlD
Context = new List<PeriodeEssaiSqlDto> 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(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) 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,8 +1,8 @@
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; } = new();
@ -46,4 +46,3 @@ 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,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 IBusinessUnitRepository : IGenericRepository<BusinessUnitSqlDto> public interface IBusinessUnitRepository : IGenericRepository<BusinessUnitSqlDto>
{ {
} }
}

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

@ -1,7 +1,7 @@
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);
@ -9,6 +9,4 @@ namespace espacecollab.backend.infrastructure.interfaces
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,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);
} }
}

@ -1,7 +1,7 @@
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; }
@ -18,7 +18,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
CollaborateurId = collaborateurId; CollaborateurId = collaborateurId;
BusinessUnitId = businessUnitId; BusinessUnitId = businessUnitId;
} }
}
} }

@ -1,7 +1,7 @@
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; }
@ -19,6 +19,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
ProjetId = projetId; ProjetId = projetId;
IsManager = isManager; IsManager = isManager;
} }
}
} }

@ -1,7 +1,7 @@
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; }
@ -17,7 +17,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
CollaborateurId = collaborateurId; CollaborateurId = collaborateurId;
FonctionId = fonctionId; FonctionId = fonctionId;
} }
}
} }

@ -18,5 +18,4 @@ public class FonctionSqlDto : IGenericIdSqlDto
Id = id; Id = id;
Name = name; Name = name;
} }
} }

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

@ -1,8 +1,8 @@
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; }
@ -27,4 +27,3 @@ namespace espacecollab.backend.infrastructure.sql.dtos
EndingDate = endingDate; EndingDate = endingDate;
} }
} }
}

@ -1,7 +1,7 @@
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; }
@ -18,4 +18,3 @@ namespace espacecollab.backend.infrastructure.sql.dtos
TechnologieId = technologieId; TechnologieId = technologieId;
} }
} }
}

@ -1,8 +1,8 @@
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; }
@ -25,4 +25,3 @@ namespace espacecollab.backend.infrastructure.sql.dtos
ReferrerId = referrerId; ReferrerId = referrerId;
} }
} }
}

@ -1,7 +1,7 @@
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; }
@ -17,8 +17,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
SiteId = siteId; SiteId = siteId;
ProjetId = projetId; ProjetId = projetId;
} }
}
} }

@ -1,8 +1,8 @@
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; }
@ -22,8 +22,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
Address = address; Address = address;
BusinessUnitId = businessUnitId; BusinessUnitId = businessUnitId;
} }
}
} }

@ -1,8 +1,8 @@
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; }
@ -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,5 +1,5 @@
namespace espacecollab.backend.infrastructure.sql.dtos.Values namespace espacecollab.backend.infrastructure.sql.dtos.Values;
{
public enum EnumIssueSql public enum EnumIssueSql
{ {
VALIDEE, VALIDEE,
@ -8,4 +8,3 @@
ARRETEE_COLLAB, ARRETEE_COLLAB,
ARRETEE_APSIDE ARRETEE_APSIDE
} }
}

@ -1,5 +1,5 @@
namespace espacecollab.backend.infrastructure.sql.dtos.Values namespace espacecollab.backend.infrastructure.sql.dtos.Values;
{
public enum EnumStatutSql public enum EnumStatutSql
{ {
CADRE, CADRE,
@ -7,4 +7,3 @@
ALTERNANT, ALTERNANT,
STAGIAIRE STAGIAIRE
} }
}

@ -2,12 +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; }
public MainDbContext(IOptions<SqlOption> sqlSettings) public MainDbContext(IOptions<SqlOption> sqlSettings)
{ {
@ -34,4 +34,3 @@ namespace espacecollab.backend.infrastructure.sql
.HasConversion<string>(); .HasConversion<string>();
} }
} }
}

@ -1,5 +1,5 @@
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";
@ -11,4 +11,3 @@
ConnectionString = string.Empty; ConnectionString = string.Empty;
} }
} }
}

@ -1,8 +1,8 @@
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)
@ -19,4 +19,3 @@ 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);
} }
}

@ -1,9 +1,8 @@
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; }
@ -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);
} }
} }
Loading…
Cancel
Save