pull/4/head
Alexandre Ruiz 3 years ago
parent 958e57db93
commit a2d1965ca7
  1. 4
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/BusinessUnitsController.cs
  2. 2
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/FonctionsController.cs
  3. 2
      Collaborateur_Epa_Back/espacecollab.backend.appservices/AgenceService.cs
  4. 10
      Collaborateur_Epa_Back/espacecollab.backend.appservices/BusinessUnitService.cs
  5. 19
      Collaborateur_Epa_Back/espacecollab.backend.appservices/BusinessUnitServices.cs
  6. 14
      Collaborateur_Epa_Back/espacecollab.backend.appservices/FonctionServices.cs
  7. 5
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeBusinessUnitRepository.cs
  8. 2
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IBusinessUnitRepository.cs
  9. 33
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/MainDbContext.cs

@ -8,9 +8,9 @@ namespace espacecollab.backend.api.Controllers
//[ApiController]
public class BusinessUnitsController : BaseController<BusinessUnitApiDto>
{
private BusinessUnitServices BusinessUnitServices { get; }
private BusinessUnitService BusinessUnitServices { get; }
public BusinessUnitsController(BusinessUnitServices businessUnitServices) : base(businessUnitServices)
public BusinessUnitsController(BusinessUnitService businessUnitServices) : base(businessUnitServices)
{
BusinessUnitServices = businessUnitServices;
}

@ -5,7 +5,7 @@ namespace espacecollab.backend.api.Controllers
{
public class FonctionsController : BaseController<FonctionApiDto>
{
public FonctionsController(FonctionServices fonctionService) : base(fonctionService)
public FonctionsController(FonctionService fonctionService) : base(fonctionService)
{
}
}

@ -5,7 +5,7 @@ using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices;
public class AgenceServices : GenericsServices<AgenceSqlDto, AgenceApiDto>
public class AgenceService : GenericsServices<AgenceSqlDto, AgenceApiDto>
{
public AgenceService(IAgenceRepository agenceRepository)
: base(agenceRepository, AgenceMapper.ToApi, AgenceMapper.ToSql)

@ -7,8 +7,14 @@ namespace espacecollab.backend.appservices;
public class BusinessUnitService : GenericsServices<BusinessUnitSqlDto, BusinessUnitApiDto>
{
public BusinessUnitService(IBusinessUnitRepository genericRepository)
: base(genericRepository, BusinessUnitMapper.ToApi, BusinessUnitMapper.ToSql)
private IBusinessUnitRepository BusinessUnitRepository { get; }
public BusinessUnitService(IBusinessUnitRepository businessUnitRepository)
:base(businessUnitRepository, BusinessUnitMapper.ToApi, BusinessUnitMapper.ToSql)
{}
public IEnumerable<BusinessUnitApiDto> GetBusinessUnitsByAgence(uint agenceId)
{
return BusinessUnitRepository.GetBusinessUnitsByAgence((int)agenceId).Select(bu => bu.ToApi());
}
}

@ -1,19 +0,0 @@
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 BusinessUnitServices : GenericsServices<BusinessUnitSqlDto, BusinessUnitApiDto>
{
private IBusinessUnitRepository BusinessUnitRepository { get; }
public BusinessUnitServices(IBusinessUnitRepository businessUnitRepository)
:base(businessUnitRepository, BusinessUnitMapper.ToApi, BusinessUnitMapper.ToSql)
{}
public IEnumerable<BusinessUnitApiDto> GetBusinessUnitsByAgence(uint agenceId)
{
return BusinessUnitRepository.GetBusinessUnitsByAgence((int)agenceId).Select(bu => bu.ToApi());
}
}

@ -1,14 +0,0 @@
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<FonctionSqlDto, FonctionApiDto>
{
public FonctionServices(IFonctionRepository fonctionRepository)
:base(fonctionRepository, FonctionMapper.ToApi, FonctionMapper.ToSql)
{
}
}

@ -13,4 +13,9 @@ public class FakeBusinessUnitRepository : GenericFakeRepository<BusinessUnitSqlD
new(2, "BU 2", 1)
};
}
public IList<BusinessUnitSqlDto> GetBusinessUnitsByAgence(int agenceId)
{
return Context.Where(c => c.AgenceId == agenceId).ToList();
}
}

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

@ -21,21 +21,20 @@ public class MainDbContext : DbContext
.EnableSensitiveDataLogging();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
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>()
.Property(e => e.Gender)
.HasConversion<string>();
modelBuilder
.Entity<CollaborateurSqlDto>()
.Property(e => e.Status)
.HasConversion<string>();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
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>()
.Property(e => e.Gender)
.HasConversion<string>();
modelBuilder
.Entity<CollaborateurSqlDto>()
.Property(e => e.Status)
.HasConversion<string>();
}
}
}
Loading…
Cancel
Save