Mise en place de l'entité Technologie

pull/7/head
Clement FERRERE 3 years ago
parent eba5a08fe8
commit 3ec4368324
  1. 12
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/TechnologiesController.cs
  2. 2
      Collaborateur_Epa_Back/espacecollab.backend.api/Register.cs
  3. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/TechnologieMapper.cs
  4. 8
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/TechnologieApiDto.cs
  5. 14
      Collaborateur_Epa_Back/espacecollab.backend.appservices/TechnologieServices.cs
  6. 8
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/ITechnologieRepository.cs
  7. 2
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/MainDbContext.cs
  8. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/TechnologieSqlRepository.cs

@ -0,0 +1,12 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
namespace espacecollab.backend.api.Controllers
{
public class TechnologiesController : BaseController<TechnologieApiDto>
{
public TechnologiesController(TechnologieServices technologieServices) : base(technologieServices)
{
}
}
}

@ -16,6 +16,7 @@ internal static class Register
services.AddScoped<AgenceServices>();
services.AddScoped<BusinessUnitServices>();
services.AddScoped<FonctionServices>();
services.AddScoped<TechnologieServices>();
if (contextOptions.LoadFake)
{
@ -29,6 +30,7 @@ internal static class Register
services.AddScoped<IAgenceRepository, AgenceSqlRepository>();
services.AddScoped<IBusinessUnitRepository, BusinessUnitSqlRepository>();
services.AddScoped<IFonctionRepository, FonctionSqlRepository>();
services.AddScoped<ITechnologieRepository, TechnologieSqlRepository>();
}
}
}

@ -0,0 +1,15 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices.dtos.Mappers;
public static class TechnologieMapper
{
public static TechnologieApiDto ToApi(this TechnologieSqlDto technologieSqlDto)
{
return new TechnologieApiDto((uint)technologieSqlDto.Id, technologieSqlDto.Name);
}
public static TechnologieSqlDto ToSql(this TechnologieApiDto technologieApiDto)
{
return new TechnologieSqlDto((int)technologieApiDto.Id, technologieApiDto.Name);
}
}

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

@ -0,0 +1,14 @@
using espacecollab.backend.appservices.dtos;
using espacecollab.backend.appservices.dtos.Mappers;
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices;
public class TechnologieServices : GenericsServices<TechnologieSqlDto, TechnologieApiDto>
{
public TechnologieServices(ITechnologieRepository technologieRepository)
:base(technologieRepository, TechnologieMapper.ToApi, TechnologieMapper.ToSql)
{
}
}

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

@ -11,6 +11,7 @@ namespace espacecollab.backend.infrastructure.sql
private DbSet<AgenceSqlDto>? Agence { get; set; }
private DbSet<BusinessUnitSqlDto>? BusinessUnit { get; set; }
private DbSet<FonctionSqlDto>? Fonction { get; set; }
private DbSet<TechnologieSqlDto>? Technologie { get; set; }
public MainDbContext(IOptions<SqlOption> sqlSettings)
{
@ -29,6 +30,7 @@ namespace espacecollab.backend.infrastructure.sql
modelBuilder.Entity<BusinessUnitSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder.Entity<AgenceSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder.Entity<FonctionSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder.Entity<TechnologieSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder.Entity<CollaborateurSqlDto>().Property(p=> p.Id).UseMySqlIdentityColumn();
modelBuilder
.Entity<CollaborateurSqlDto>()

@ -0,0 +1,11 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.infrastructure.sql.Repository;
public class TechnologieSqlRepository : GenericSqlRepository<TechnologieSqlDto>, ITechnologieRepository
{
public TechnologieSqlRepository(MainDbContext context) : base(context)
{
}
}
Loading…
Cancel
Save