rework_referencement #13

Merged
AlexandreRuiz merged 3 commits from rework_referencement into develop 2 years ago
  1. 10
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/CollaborateursController.cs
  2. 13
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/ReferencementsController.cs
  3. 2
      Collaborateur_Epa_Back/espacecollab.backend.api/Register.cs
  4. 4
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/CollaborateurApiDto.cs
  5. 8
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/CollaborateurMapper.cs
  6. 15
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/Mappers/ReferencementMapper.cs
  7. 12
      Collaborateur_Epa_Back/espacecollab.backend.appservices.dtos/ReferencementApiDto.cs
  8. 5
      Collaborateur_Epa_Back/espacecollab.backend.appservices/CollaborateursService.cs
  9. 18
      Collaborateur_Epa_Back/espacecollab.backend.appservices/ReferencementService.cs
  10. 9
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.fake/FakeCollaborateurRepository.cs
  11. 1
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/ICollaborateurRepository.cs
  12. 2
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.interfaces/IReferencementRepository.cs
  13. 4
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/CollaborateurSqlDto.cs
  14. 4
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql.dtos/ReferencementSqlDto.cs
  15. 3
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/MainDbContext.cs
  16. 3
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/CollaborateurSqlRepository.cs
  17. 11
      Collaborateur_Epa_Back/espacecollab.backend.infrastructure.sql/Repository/ReferencementSqlRepository.cs

@ -71,16 +71,6 @@ public class CollaborateursController : BaseController<CollaborateurApiDto>
return Ok(collaborateurs);
}
[HttpGet("referrer/{referrerId:int:min(1)}")]
public ActionResult<IEnumerable<CollaborateurApiDto>> GetCollaborateursByReferrer(uint referrerId)
{
IEnumerable<CollaborateurApiDto> collaborateurs = CollaborateursServices.GetCollaborateursByReferrer(referrerId);
if (!collaborateurs.Any())
return NotFound();
return Ok(collaborateurs);
}
[HttpGet("apsidemail/{apsideMail:minlength(1):regex(^\\S.*)}")]
public ActionResult<CollaborateurApiDto> GetCollaborateurByApsideMail(string apsideMail)
{

@ -0,0 +1,13 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
using Microsoft.AspNetCore.Mvc;
namespace espacecollab.backend.api.Controllers;
public class ReferencementsController : BaseController<ReferencementApiDto>
{
public ReferencementsController(ReferencementService referencementServices) : base(referencementServices)
{
}
}

@ -17,6 +17,7 @@ internal static class Register
services.AddScoped<BusinessUnitService>();
services.AddScoped<FonctionService>();
services.AddScoped<PeriodeEssaiService>();
services.AddScoped<ReferencementService>();
if (contextOptions.LoadFake)
{
@ -35,6 +36,7 @@ internal static class Register
services.AddScoped<IFonctionRepository, FonctionSqlRepository>();
services.AddScoped<ITechnologieRepository, TechnologieSqlRepository>();
services.AddScoped<IPeriodeEssaiRepository, PeriodeEssaiSqlRepository>();
services.AddScoped<IReferencementRepository, ReferencementSqlRepository>();
}
}
}

@ -3,8 +3,8 @@ using espacecollab.backend.appservices.dtos.Values;
namespace espacecollab.backend.appservices.dtos;
public record CollaborateurApiDto(uint Id, string Name, string FirstName, DateTime BirthDate, EnumGenreApi Gender, EnumStatutApi Status, int ChildrenNumber, string Address,
string Telephone, string PersonalMail, string ApsideMail, DateTime? ResignationDate, int ReferrerId, int BusinessUnitId) : IGenericIdApiDto
public record CollaborateurApiDto(uint Id, string Name, string FirstName, DateTime BirthDate, EnumGenreApi Gender, EnumStatutApi Status, uint ChildrenNumber, string Address,
string Telephone, string PersonalMail, string ApsideMail, DateTime? ResignationDate, uint BusinessUnitId) : IGenericIdApiDto
{
public uint Id { get; set; } = Id;
}

@ -7,16 +7,16 @@ public static class CollaborateurMapper
public static CollaborateurApiDto ToApi(this CollaborateurSqlDto collaborateurSql)
{
return new CollaborateurApiDto((uint)collaborateurSql.Id, collaborateurSql.Name, collaborateurSql.FirstName,
collaborateurSql.BirthDate, collaborateurSql.Gender.ToEnumGenreApi(), collaborateurSql.Status.ToEnumStatutApi(), collaborateurSql.ChildrenNumber,
collaborateurSql.BirthDate, collaborateurSql.Gender.ToEnumGenreApi(), collaborateurSql.Status.ToEnumStatutApi(), (uint)collaborateurSql.ChildrenNumber,
collaborateurSql.Address, collaborateurSql.Telephone, collaborateurSql.PersonalMail, collaborateurSql.ApsideMail,
collaborateurSql.ResignationDate, collaborateurSql.ReferrerId, collaborateurSql.BusinessUnitId);
collaborateurSql.ResignationDate, (uint)collaborateurSql.BusinessUnitId);
}
public static CollaborateurSqlDto ToSql(this CollaborateurApiDto collaborateurApi)
{
return new CollaborateurSqlDto((int)collaborateurApi.Id, collaborateurApi.Name, collaborateurApi.FirstName,
collaborateurApi.BirthDate, collaborateurApi.Gender.ToEnumGenreSql(), collaborateurApi.Status.ToEnumStatutSql(), collaborateurApi.ChildrenNumber,
collaborateurApi.BirthDate, collaborateurApi.Gender.ToEnumGenreSql(), collaborateurApi.Status.ToEnumStatutSql(), (int)collaborateurApi.ChildrenNumber,
collaborateurApi.Address, collaborateurApi.Telephone, collaborateurApi.PersonalMail, collaborateurApi.ApsideMail,
collaborateurApi.ResignationDate, collaborateurApi.ReferrerId, collaborateurApi.BusinessUnitId);
collaborateurApi.ResignationDate, (int)collaborateurApi.BusinessUnitId);
}
}

@ -0,0 +1,15 @@
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.appservices.dtos.Mappers;
public static class ReferencementMapper
{
public static ReferencementApiDto ToApi(this ReferencementSqlDto referencementSqlDto)
{
return new ReferencementApiDto((uint)referencementSqlDto.Id, referencementSqlDto.StartingDate,referencementSqlDto.EndingDate,(uint)referencementSqlDto.ReferredId, (uint)referencementSqlDto.ReferrerId);
}
public static ReferencementSqlDto ToSql(this ReferencementApiDto referencementApiDto)
{
return new ReferencementSqlDto((int)referencementApiDto.Id, referencementApiDto.StartingDate, referencementApiDto.EndingDate, (int)referencementApiDto.ReferredId, (int)referencementApiDto.ReferrerId);
}
}

@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using espacecollab.backend.appservices.dtos.Interfaces;
using espacecollab.backend.infrastructure.sql.dtos.Interfaces;
namespace espacecollab.backend.appservices.dtos;
public record ReferencementApiDto(uint Id, DateTime StartingDate, DateTime? EndingDate, uint ReferredId, uint ReferrerId) : IGenericIdApiDto
{
public uint Id { get; set; } = Id;
}

@ -57,11 +57,6 @@ public class CollaborateursService : GenericsServices<CollaborateurSqlDto, Colla
return CollaborateurRepository.GetCollaborateursByBusinessUnit((int)businessUnitId).Select(collaborateurSql => collaborateurSql.ToApi());
}
public IEnumerable<CollaborateurApiDto> GetCollaborateursByReferrer(uint referrerId)
{
return CollaborateurRepository.GetCollaborateursByReferrer((int)referrerId).Select(collaborateurSql => collaborateurSql.ToApi());
}
public CollaborateurApiDto? GetCollaborateurByApsideMail(string apsideMail)
{
if (string.IsNullOrEmpty(apsideMail))

@ -0,0 +1,18 @@
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 ReferencementService : GenericsServices<ReferencementSqlDto, ReferencementApiDto>
{
private IReferencementRepository ReferencementRepository { get; }
public ReferencementService(IReferencementRepository referencementRepository)
: base(referencementRepository, ReferencementMapper.ToApi, ReferencementMapper.ToSql)
{
ReferencementRepository = referencementRepository;
}
}

@ -12,10 +12,10 @@ public class FakeCollaborateurRepository : GenericFakeRepository<CollaborateurSq
{
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),
"jean.dupont@gmail.com", "jean.dupont@apside-groupe.com", new DateTime(2023, 12, 17), 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)
"laura.michel@gmail.com", "laura.michel@apside-groupe.com", new DateTime(2023, 12, 17), 1)
};
}
@ -26,11 +26,6 @@ public class FakeCollaborateurRepository : GenericFakeRepository<CollaborateurSq
return Context.Where(entity => entity.BusinessUnitId == businessUnitId).ToList();
}
public IList<CollaborateurSqlDto> GetCollaborateursByReferrer(int referrerId)
{
return Context.Where(entity => entity.ReferrerId == referrerId).ToList();
}
public CollaborateurSqlDto GetCollaborateurByApsideMail(string apsideMail)
{
return Context.First(entity => entity.ApsideMail == apsideMail);

@ -6,5 +6,4 @@ public interface ICollaborateurRepository : IGenericRepository<CollaborateurSqlD
{
CollaborateurSqlDto? GetCollaborateurByApsideMail(string apsideMail);
IList<CollaborateurSqlDto> GetCollaborateursByBusinessUnit(int businessUnitId);
IList<CollaborateurSqlDto> GetCollaborateursByReferrer(int referrerId);
}

@ -4,6 +4,4 @@ namespace espacecollab.backend.infrastructure.interfaces;
public interface IReferencementRepository : IGenericRepository<ReferencementSqlDto>
{
IList<CollaborateurSqlDto>? GetReferrersByCollaborateurId(int collaborateurId);
IList<CollaborateurSqlDto>? GetReferrersByCollaborateurApsideMail(string apsideMail);
}

@ -22,7 +22,6 @@ public class CollaborateurSqlDto : IGenericIdSqlDto
public string PersonalMail { get; set; }
public string ApsideMail { get; set; }
public DateTime? ResignationDate { get; set; }
public int ReferrerId { get; set; }
public int BusinessUnitId { get; set; }
[ExcludeFromCodeCoverage]
@ -36,7 +35,7 @@ public class CollaborateurSqlDto : IGenericIdSqlDto
ApsideMail = string.Empty;
}
public CollaborateurSqlDto(int id, string name, string firstName, DateTime birthDate, EnumGenreSql gender, EnumStatutSql status, int childrenNumber, string address, string telephone, string personalMail, string apsideMail, DateTime? resignationDate, int referrerId, int businessUnitId)
public CollaborateurSqlDto(int id, string name, string firstName, DateTime birthDate, EnumGenreSql gender, EnumStatutSql status, int childrenNumber, string address, string telephone, string personalMail, string apsideMail, DateTime? resignationDate, int businessUnitId)
{
Id = id;
Name = name;
@ -50,7 +49,6 @@ public class CollaborateurSqlDto : IGenericIdSqlDto
PersonalMail = personalMail;
ApsideMail = apsideMail;
ResignationDate = resignationDate;
ReferrerId = referrerId;
BusinessUnitId = businessUnitId;
}
}

@ -11,7 +11,7 @@ public class ReferencementSqlDto : IGenericIdSqlDto
[Key]
public int Id { get; set; }
public DateTime StartingDate { get; set; }
public DateTime EndingDate { get; set; }
public DateTime? EndingDate { get; set; }
public int ReferredId { get; set; }
public int ReferrerId { get; set; }
@ -20,7 +20,7 @@ public class ReferencementSqlDto : IGenericIdSqlDto
{
}
public ReferencementSqlDto(int id, DateTime startingDate, DateTime endingDate, int referredId, int referrerId)
public ReferencementSqlDto(int id, DateTime startingDate, DateTime? endingDate, int referredId, int referrerId)
{
Id = id;
StartingDate = startingDate;

@ -32,6 +32,7 @@ public class MainDbContext : DbContext
modelBuilder.Entity<TechnologieSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder.Entity<PeriodeEssaiSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
modelBuilder
.Entity<PeriodeEssaiSqlDto>()
.Property(e => e.Issue)
@ -46,5 +47,7 @@ public class MainDbContext : DbContext
.Entity<CollaborateurSqlDto>()
.Property(e => e.Status)
.HasConversion<string>();
modelBuilder.Entity<ReferencementSqlDto>().Property(p => p.Id).UseMySqlIdentityColumn();
}
}

@ -13,9 +13,6 @@ public class CollaborateurSqlRepository : GenericSqlRepository<CollaborateurSqlD
public IList<CollaborateurSqlDto> GetCollaborateursByBusinessUnit(int businessUnitId)
=> Context.Set<CollaborateurSqlDto>().Where(collaborateur => collaborateur.BusinessUnitId == businessUnitId).ToList();
public IList<CollaborateurSqlDto> GetCollaborateursByReferrer(int referrerId)
=> Context.Set<CollaborateurSqlDto>().Where(collaborateur => collaborateur.ReferrerId == referrerId).ToList();
public CollaborateurSqlDto? GetCollaborateurByApsideMail(string apsideMail)
=> Context?.Set<CollaborateurSqlDto>().SingleOrDefault(collaborateur => collaborateur.ApsideMail == apsideMail);
}

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