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

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

@ -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)
{
CreateHostBuilder(args).Build().Run();
@ -13,5 +13,4 @@ namespace espacecollab.backend.api
{
webBuilder.UseStartup<Startup>();
});
}
}

@ -12,7 +12,7 @@ internal static class Register
public static void InjectDependencies(IServiceCollection services, SqlOption contextOptions)
{
services.AddCors();
services.AddScoped<CollaborateursServices>();
services.AddScoped<CollaborateursService>();
services.AddScoped<AgenceService>();
services.AddScoped<BusinessUnitService>();
services.AddScoped<FonctionService>();

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

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

@ -1,11 +1,10 @@
using espacecollab.backend.appservices.dtos.Interfaces;
using espacecollab.backend.appservices.dtos.Values;
namespace espacecollab.backend.appservices.dtos
{
public record CollaborateurApiDto(uint Id, string Name, string FirstName, string BirthDate, EnumGenreApi Gender, EnumStatutApi Status, int ChildrenNumber, string Address,
namespace espacecollab.backend.appservices.dtos;
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;
}
}

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

@ -1,10 +1,10 @@
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)
{
return new CollaborateurApiDto((uint)collaborateurSql.Id, collaborateurSql.Name, collaborateurSql.FirstName,
@ -16,9 +16,8 @@ namespace espacecollab.backend.appservices.dtos.Mappers
public static CollaborateurSqlDto ToSql(this CollaborateurApiDto collaborateurApi)
{
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,
DateTime.ParseExact(collaborateurApi.BirthDate, "dd/MM/yyyy", CultureInfo.InvariantCulture), collaborateurApi.Gender.ToEnumGenreSql(), collaborateurApi.Status.ToEnumStatutSql(), collaborateurApi.ChildrenNumber,
collaborateurApi.Address, collaborateurApi.Telephone, collaborateurApi.PersonalMail, collaborateurApi.ApsideMail,
DateTime.ParseExact(collaborateurApi.ResignationDate, "dd/MM/yyyy", CultureInfo.InvariantCulture), collaborateurApi.ReferrerId, collaborateurApi.BusinessUnitId);
}
}
}

@ -1,10 +1,10 @@
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)
{
return enumGenreSql switch
@ -26,5 +26,4 @@ namespace espacecollab.backend.appservices.dtos.Mappers
_ => EnumGenreSql.AUTRE,
};
}
}
}

@ -1,10 +1,10 @@
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)
{
return enumStatutSql switch
@ -28,5 +28,4 @@ namespace espacecollab.backend.appservices.dtos.Mappers
_ => EnumStatutSql.NONCADRE,
};
}
}
}

@ -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;
namespace espacecollab.backend.appservices.dtos.Mappers;

@ -1,5 +1,5 @@
using espacecollab.backend.appservices.dtos.Interfaces;
using espacecollab.backend.infrastructure.sql.dtos.Values;
using espacecollab.backend.appservices.dtos.Values;
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,
FEMININ,
AUTRE
}
}

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

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

@ -1,9 +1,9 @@
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);
IEnumerable<T> GetAll();
@ -13,5 +13,4 @@ namespace espacecollab.backend.appservices.interfaces
T? Update(T apiDto);
bool Delete(uint apiDtoId);
}
}

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

@ -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.sql.dtos;

@ -3,10 +3,10 @@ using espacecollab.backend.appservices.dtos.Mappers;
using espacecollab.backend.infrastructure.interfaces;
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; }
public CollaborateursService(ICollaborateurRepository collaborateurRepository)
@ -32,5 +32,4 @@ namespace espacecollab.backend.appservices
return CollaborateurRepository.GetCollaborateurByApsideMail(apsideMail)?.ToApi();
}
}
}

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

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

@ -1,18 +1,16 @@
using espacecollab.backend.infrastructure.interfaces;
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()
{
Context = new List<AgenceSqlDto>
{
new(1, "Tours"),
new(2, "Clermont-Ferrand")
};
}
}
}

@ -1,18 +1,16 @@
using espacecollab.backend.infrastructure.interfaces;
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()
{
Context = new List<BusinessUnitSqlDto>
{
new(1, "BU 1", 1),
new(2, "BU 2", 1)
};
}
}
}

@ -2,10 +2,10 @@
using espacecollab.backend.infrastructure.sql.dtos;
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()
{
Context = new List<CollaborateurSqlDto>
@ -13,7 +13,6 @@ namespace espacecollab.backend.infrastructure.fake
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)
@ -38,5 +37,4 @@ namespace espacecollab.backend.infrastructure.fake
}
#endregion
}
}

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

@ -11,7 +11,6 @@ public class FakePeriodeEssaiRepository : GenericFakeRepository<PeriodeEssaiSqlD
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,10 +1,10 @@
using espacecollab.backend.infrastructure.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();
public virtual T? Add(T entity)
@ -45,5 +45,4 @@ namespace espacecollab.backend.infrastructure.fake
return Context.FirstOrDefault(e => e.Id == entity.Id);
}
}
}

@ -1,8 +1,7 @@
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;
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;
namespace espacecollab.backend.infrastructure.interfaces
namespace espacecollab.backend.infrastructure.interfaces;
public interface ICollaborateurRepository : IGenericRepository<CollaborateurSqlDto>
{
public interface ICollaborateurRepository : IGenericRepository<CollaborateurSqlDto>
{
CollaborateurSqlDto? GetCollaborateurByApsideMail(string apsideMail);
IList<CollaborateurSqlDto> GetCollaborateursByBusinessUnit(int businessUnitId);
IList<CollaborateurSqlDto> GetCollaborateursByReferrer(int referrerId);
}
}

@ -1,14 +1,12 @@
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);
bool Delete(int entityId);
IEnumerable<T> GetAll();
T? GetById(int id);
T? Update(T entity);
//void GetAll<T>() where T : class, IGenericSqlDto;
}
}

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

@ -1,10 +1,9 @@
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>? GetReferrersByCollaborateurApsideMail(string apsideMail);
}
}

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

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

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

@ -18,5 +18,4 @@ public class FonctionSqlDto : IGenericIdSqlDto
Id = id;
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; }
}
}

@ -1,10 +1,10 @@
using System.Diagnostics.CodeAnalysis;
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 string Name { get; set; }
public string Client { get; set; }
@ -26,5 +26,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
StartingDate = startingDate;
EndingDate = endingDate;
}
}
}

@ -1,9 +1,9 @@
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 TechnologieId { get; set; }
@ -17,5 +17,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
ProjetId = projetId;
TechnologieId = technologieId;
}
}
}

@ -1,10 +1,10 @@
using System.Diagnostics.CodeAnalysis;
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 DateTime StartingDate { get; set; }
public DateTime EndingDate { get; set; }
@ -24,5 +24,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
ReferredId = referredId;
ReferrerId = referrerId;
}
}
}

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

@ -1,10 +1,10 @@
using System.Diagnostics.CodeAnalysis;
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 string Name { get; set; }
public string Address { get; set; }
@ -22,8 +22,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
Address = address;
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 string Name { get; set; }
@ -18,6 +18,4 @@ namespace espacecollab.backend.infrastructure.sql.dtos
Id = id;
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,
FEMININ,
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,
PROLONGEE_COLLAB,
PROLONGEE_APSIDE,
ARRETEE_COLLAB,
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,
NONCADRE,
ALTERNANT,
STAGIAIRE
}
}

@ -2,12 +2,12 @@
using espacecollab.backend.infrastructure.sql.Options;
using Microsoft.EntityFrameworkCore;
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 DbSet<CollaborateurSqlDto>? Collaborateur { get; set; }
public MainDbContext(IOptions<SqlOption> sqlSettings)
{
@ -23,7 +23,7 @@ namespace espacecollab.backend.infrastructure.sql
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<CollaborateurSqlDto>().Property(p=> p.Id).UseMySqlIdentityColumn();
modelBuilder.Entity<CollaborateurSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder
.Entity<CollaborateurSqlDto>()
.Property(e => e.Gender)
@ -33,5 +33,4 @@ namespace espacecollab.backend.infrastructure.sql
.Property(e => e.Status)
.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 bool LoadFake { get; set; }
public string ConnectionString { get; set; }
@ -10,5 +10,4 @@
{
ConnectionString = string.Empty;
}
}
}

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

@ -1,11 +1,10 @@
using espacecollab.backend.infrastructure.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; }
public GenericSqlRepository(MainDbContext context)
@ -17,14 +16,16 @@ namespace espacecollab.backend.infrastructure.sql.Repository
{
Context.Set<T>().Add(entity);
Context.SaveChanges();
return entity;
return entity;
}
public virtual bool Delete(int entityId)
{
T? entity = GetById(entityId);
if (entity == null) return false;
if (entity == null)
return false;
Context.Set<T>().Remove(entity);
return Context.SaveChanges() == 1;
@ -37,14 +38,14 @@ namespace espacecollab.backend.infrastructure.sql.Repository
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)
{
Context.Set<T>().Update(entity);
Context.SaveChanges();
return Context.Set<T>().FirstOrDefault(e => e.Id == entity.Id);
}
return GetById(entity.Id);
}
}
Loading…
Cancel
Save