Periode essaie

pull/4/head
Alexandre Ruiz 3 years ago
parent d683ef85e7
commit eecdf57f36
  1. 11
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/PeriodeEssai.cs
  2. 3
      Collaborateur_Epa_Back/espacecollab.backend.api/Register.cs
  3. 21
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/PeriodeEssaiMapper.cs
  4. 9
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/PeriodeEssaiApiDto.cs
  5. 11
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Values/EnumIssueApi.cs
  6. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices/PeriodeEssaiService.cs
  7. 18
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakePeriodeEssaiRepository.cs
  8. 7
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IPeriodeEssaiRepository.cs
  9. 49
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/PeriodeEssaiSqlDto.cs
  10. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/PeriodeEssaiSqlRepository.cs

@ -0,0 +1,11 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
namespace espacecollab.backend.api.Controllers;
public class PeriodeEssaiController : BaseController<PeriodeEssaiApiDto>
{
public PeriodeEssaiController(PeriodeEssaiService periodeEssaiService) : base(periodeEssaiService)
{
}
}

@ -15,6 +15,7 @@ internal static class Register
services.AddScoped<AgenceService>(); services.AddScoped<AgenceService>();
services.AddScoped<BusinessUnitService>(); services.AddScoped<BusinessUnitService>();
services.AddScoped<FonctionService>(); services.AddScoped<FonctionService>();
services.AddScoped<PeriodeEssaiService>();
if (contextOptions.LoadFake) if (contextOptions.LoadFake)
{ {
@ -22,6 +23,7 @@ internal static class Register
services.AddSingleton<IAgenceRepository, FakeAgenceRepository>(); services.AddSingleton<IAgenceRepository, FakeAgenceRepository>();
services.AddSingleton<IBusinessUnitRepository, FakeBusinessUnitRepository>(); services.AddSingleton<IBusinessUnitRepository, FakeBusinessUnitRepository>();
services.AddSingleton<IFonctionRepository, FakeFonctionRepository>(); services.AddSingleton<IFonctionRepository, FakeFonctionRepository>();
services.AddSingleton<IPeriodeEssaiRepository, FakePeriodeEssaiRepository>();
} }
else else
{ {
@ -30,6 +32,7 @@ internal static class Register
services.AddScoped<IAgenceRepository, AgenceSqlRepository>(); services.AddScoped<IAgenceRepository, AgenceSqlRepository>();
services.AddScoped<IBusinessUnitRepository, BusinessUnitSqlRepository>(); services.AddScoped<IBusinessUnitRepository, BusinessUnitSqlRepository>();
services.AddScoped<IFonctionRepository, FonctionSqlRepository>(); services.AddScoped<IFonctionRepository, FonctionSqlRepository>();
services.AddScoped<IPeriodeEssaiRepository, PeriodeEssaiSqlRepository>();
} }
} }
} }

@ -0,0 +1,21 @@
using espacecollab.backend.infrastructure.sql.dtos;
using espacecollab.backend.infrastructure.sql.dtos.Values;
namespace espacecollab.backend.appservices.dtos.Mappers;
public static class PeriodeEssaiMapper
{
public static PeriodeEssaiApiDto ToApi(this PeriodeEssaiSqlDto periodeEssaiSqlDto)
{
return new PeriodeEssaiApiDto((uint)periodeEssaiSqlDto.Id, periodeEssaiSqlDto.StartingDate,
periodeEssaiSqlDto.PlannedEndingDate, periodeEssaiSqlDto.RealEndingDate, periodeEssaiSqlDto.Comment,
(EnumIssueApi)periodeEssaiSqlDto.Issue, (uint)periodeEssaiSqlDto.CollaborateurId);
}
public static PeriodeEssaiSqlDto ToSql(this PeriodeEssaiApiDto periodeEssaiApiDto)
{
return new PeriodeEssaiSqlDto((int)periodeEssaiApiDto.Id, periodeEssaiApiDto.StartingDate,
periodeEssaiApiDto.PlannedEndingDate, periodeEssaiApiDto.RealEndingDate, periodeEssaiApiDto.Comment,
(EnumIssueSql)periodeEssaiApiDto.Issue, (int)periodeEssaiApiDto.CollaborateurId);
}
}

@ -0,0 +1,9 @@
using espacecollab.backend.appservices.dtos.Interfaces;
using espacecollab.backend.infrastructure.sql.dtos.Values;
namespace espacecollab.backend.appservices.dtos;
public record PeriodeEssaiApiDto(uint Id, DateTime StartingDate, DateTime PlannedEndingDate, DateTime RealEndingDate, string Comment, EnumIssueApi Issue, uint CollaborateurId) : IGenericIdApiDto
{
public uint Id { get; set; } = Id;
}

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

@ -0,0 +1,15 @@
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 PeriodeEssaiService : GenericsServices<PeriodeEssaiSqlDto, PeriodeEssaiApiDto>
{
public PeriodeEssaiService(IPeriodeEssaiRepository agenceRepository)
: base(agenceRepository, PeriodeEssaiMapper.ToApi, PeriodeEssaiMapper.ToSql)
{
}
}

@ -0,0 +1,18 @@
using espacecollab.backend.infrastructure.interfaces;
using espacecollab.backend.infrastructure.sql.dtos;
using espacecollab.backend.infrastructure.sql.dtos.Values;
namespace espacecollab.backend.infrastructure.fake;
public class FakePeriodeEssaiRepository : GenericFakeRepository<PeriodeEssaiSqlDto>, IPeriodeEssaiRepository
{
public FakePeriodeEssaiRepository()
{
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,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 IPeriodeEssaiRepository : IGenericRepository<PeriodeEssaiSqlDto>
{ {
public interface IPeriodeEssaiRepository : IGenericRepository<PeriodeEssaiSqlDto>
{
}
} }

@ -2,33 +2,32 @@
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 PeriodeEssaiSqlDto : IGenericIdSqlDto
{ {
public class PeriodeEssaiSqlDto : IGenericIdSqlDto public int Id { get; set; }
{ public DateTime StartingDate { get; set; }
public int Id { get; set; } public DateTime PlannedEndingDate { get; set; }
public DateTime StartingDate { get; set; } public DateTime RealEndingDate { get; set; }
public DateTime PlannedEndingDate { get; set; } public string Comment { get; set; }
public DateTime RealEndingDate { get; set; } public EnumIssueSql Issue { get; set; }
public string Comment { get; set; } public int CollaborateurId { get; set; }
public EnumIssueSql Issue { get; set; }
public int CollaborateurId { get; set; }
[ExcludeFromCodeCoverage] [ExcludeFromCodeCoverage]
private PeriodeEssaiSqlDto() private PeriodeEssaiSqlDto()
{ {
Comment = string.Empty; Comment = string.Empty;
} }
public PeriodeEssaiSqlDto(int id, DateTime startingDate, DateTime plannedEndingDate, DateTime realEndingDate, string comment, EnumIssueSql issue, int collaborateurId) public PeriodeEssaiSqlDto(int id, DateTime startingDate, DateTime plannedEndingDate, DateTime realEndingDate, string comment, EnumIssueSql issue, int collaborateurId)
{ {
Id = id; Id = id;
StartingDate = startingDate; StartingDate = startingDate;
PlannedEndingDate = plannedEndingDate; PlannedEndingDate = plannedEndingDate;
RealEndingDate = realEndingDate; RealEndingDate = realEndingDate;
Comment = comment; Comment = comment;
Issue = issue; Issue = issue;
CollaborateurId = collaborateurId; CollaborateurId = collaborateurId;
}
} }
} }

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