diff --git a/Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/FonctionsController.cs b/Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/FonctionsController.cs new file mode 100644 index 0000000..431862a --- /dev/null +++ b/Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/FonctionsController.cs @@ -0,0 +1,12 @@ +using espacecollab.backend.appservices; +using espacecollab.backend.appservices.dtos; + +namespace espacecollab.backend.api.Controllers +{ + public class FonctionsController : BaseController + { + public FonctionsController(FonctionServices fonctionService) : base(fonctionService) + { + } + } +} diff --git a/Collaborateur_Epa_Back/espacecollab.backend.api/Register.cs b/Collaborateur_Epa_Back/espacecollab.backend.api/Register.cs index 5c2b55f..8012c98 100644 --- a/Collaborateur_Epa_Back/espacecollab.backend.api/Register.cs +++ b/Collaborateur_Epa_Back/espacecollab.backend.api/Register.cs @@ -15,6 +15,7 @@ internal static class Register services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); if (contextOptions.LoadFake) { @@ -27,6 +28,7 @@ internal static class Register services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); } } } \ No newline at end of file diff --git a/Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/FonctionApiDto.cs b/Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/FonctionApiDto.cs new file mode 100644 index 0000000..a839b9e --- /dev/null +++ b/Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/FonctionApiDto.cs @@ -0,0 +1,8 @@ +using espacecollab.backend.appservices.dtos.Interfaces; + +namespace espacecollab.backend.appservices.dtos; + +public record FonctionApiDto(uint Id, string Intitule) : IGenericIdApiDto +{ + public uint Id { get; set; } = Id; +} \ No newline at end of file diff --git a/Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/FonctionMapper.cs b/Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/FonctionMapper.cs new file mode 100644 index 0000000..1084d60 --- /dev/null +++ b/Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/FonctionMapper.cs @@ -0,0 +1,15 @@ +using espacecollab.backend.infrastructure.sql.dtos; + +namespace espacecollab.backend.appservices.dtos.Mappers; + +public static class FonctionMapper +{ + public static FonctionApiDto ToApi(this FonctionSqlDto fonctionSqlDto) + { + return new FonctionApiDto((uint)fonctionSqlDto.Id, fonctionSqlDto.Intitule); + } + public static FonctionSqlDto ToSql(this FonctionApiDto fonctionApiDto) + { + return new FonctionSqlDto((int)fonctionApiDto.Id, fonctionApiDto.Intitule); + } +} \ No newline at end of file diff --git a/Collaborateur_Epa_Back/espacecollab.backend.appservices/FonctionServices.cs b/Collaborateur_Epa_Back/espacecollab.backend.appservices/FonctionServices.cs new file mode 100644 index 0000000..ad02b9a --- /dev/null +++ b/Collaborateur_Epa_Back/espacecollab.backend.appservices/FonctionServices.cs @@ -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 FonctionServices : GenericsServices +{ + public FonctionServices(IFonctionRepository fonctionRepository) + :base(fonctionRepository, FonctionMapper.ToApi, FonctionMapper.ToSql) + { + } +} \ No newline at end of file diff --git a/Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IFonctionRepository.cs b/Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IFonctionRepository.cs new file mode 100644 index 0000000..633c38b --- /dev/null +++ b/Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IFonctionRepository.cs @@ -0,0 +1,8 @@ +using espacecollab.backend.infrastructure.sql.dtos; + +namespace espacecollab.backend.infrastructure.interfaces +{ + public interface IFonctionRepository : IGenericRepository + { + } +} \ No newline at end of file diff --git a/Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/FonctionSqlDto.cs b/Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/FonctionSqlDto.cs index 0d67697..f66a969 100644 --- a/Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/FonctionSqlDto.cs +++ b/Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/FonctionSqlDto.cs @@ -6,17 +6,17 @@ namespace espacecollab.backend.infrastructure.sql.dtos public class FonctionSqlDto : IGenericIdSqlDto { public int Id { get; set; } - public string Name { get; set; } + public string Intitule { get; set; } [ExcludeFromCodeCoverage] private FonctionSqlDto() { } - public FonctionSqlDto(int id, string name) + public FonctionSqlDto(int id, string intitule) { Id = id; - Name = name; + Intitule = intitule; } diff --git a/Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/MainDbContext.cs b/Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/MainDbContext.cs index 9077ed2..ceb2e44 100644 --- a/Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/MainDbContext.cs +++ b/Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/MainDbContext.cs @@ -10,6 +10,7 @@ namespace espacecollab.backend.infrastructure.sql private DbSet? Collaborateur { get; set; } private DbSet? Agence { get; set; } private DbSet? BusinessUnit { get; set; } + private DbSet? Fonction { get; set; } public MainDbContext(IOptions sqlSettings) { @@ -27,6 +28,7 @@ namespace espacecollab.backend.infrastructure.sql { modelBuilder.Entity().Property(p => p.Id).UseMySqlIdentityColumn(); modelBuilder.Entity().Property(p => p.Id).UseMySqlIdentityColumn(); + modelBuilder.Entity().Property(p => p.Id).UseMySqlIdentityColumn(); modelBuilder.Entity().Property(p=> p.Id).UseMySqlIdentityColumn(); modelBuilder .Entity() diff --git a/Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/FonctionSqlRepository.cs b/Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/FonctionSqlRepository.cs new file mode 100644 index 0000000..5f79650 --- /dev/null +++ b/Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/FonctionSqlRepository.cs @@ -0,0 +1,11 @@ +using espacecollab.backend.infrastructure.interfaces; +using espacecollab.backend.infrastructure.sql.dtos; + +namespace espacecollab.backend.infrastructure.sql.Repository; + +public class FonctionSqlRepository : GenericSqlRepository, IFonctionRepository +{ + public FonctionSqlRepository(MainDbContext context) : base(context) + { + } +} \ No newline at end of file