Implémentation de la récupération d'une demande de délégation avec un EP

develop
Yanaël GRETTE 3 years ago
parent 2fbd2076cd
commit 72153decaf
  1. 20
      EPAServeur.Tests/Services/EpDetailsServiceTests.cs
  2. 30
      EPAServeur/Context/DataSeeder.cs
  3. 4
      EPAServeur/DTO/EpDTO.cs
  4. 2
      EPAServeur/IServices/ITransformDTO.cs
  5. 4
      EPAServeur/Services/EpDetailsService.cs
  6. 21
      EPAServeur/Services/TransformDTO.cs

@ -148,6 +148,24 @@ namespace EPAServeur.Tests.Services
}
#endregion
#region Récupérer EP avec demandes de délégation
[TestCase(1, false)]
[TestCase(2, true)]
[TestCase(4, true)]
[TestCase(8, true)]
[TestCase(9, false)]
[TestCase(12, false)]
public async Task GetEpById_GetDemandeDelegation(long idEp, bool possedeDemandeDelegation)
{
IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService);
EpDTO epDTO = await epDetailsService.GetEp(idEp);
if(possedeDemandeDelegation)
Assert.IsNotNull(epDTO.DemandesDelegation);
else
Assert.IsNull(epDTO.DemandesDelegation);
}
#endregion
#region Récupérer EP avec RDV entretiens
#endregion
@ -155,8 +173,6 @@ namespace EPAServeur.Tests.Services
#endregion
#region Récupérer EP avec demandes de délégation
#endregion
#region Récupérer EP avec demandes de formation
#endregion

@ -87,6 +87,7 @@ namespace EPAServeur.Context
Engagement eg1, eg2, eg3, eg4;
ParticipationEP p1, p2, p3, p4, p5;
CommentaireAssistant ca1, ca2, ca3;
DemandeDelegation dm1, dm2, dm3;
//Ep en cours
Ep epEnCours1, epEnCours2, epEnCours3, epEnCours4, epEnCours5, epEnCours6, epEnCours7, epEnCours8, epEnCours9;
@ -131,6 +132,15 @@ namespace EPAServeur.Context
Ep = epEnCours2
};
epEnCours2.CommentairesAssistant = new List<CommentaireAssistant>(new[] { ca1, ca2 });
dm1 = new DemandeDelegation()
{
DateDemande = DateTime.Now,
Ep = epEnCours1,
IdReferent = new Guid("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d"),
EtatDemande = EtatDemande.EnAttente,
RaisonDemande = "Raison quelconque 1"
};
epEnCours2.DemandeDelegation = dm1;
epContext.Ep.Add(epEnCours2);
@ -175,6 +185,15 @@ namespace EPAServeur.Context
IdCollaborateur = new Guid("a0f40e2a-cc03-4032-a627-5389e1281c64"),
Obligatoire = false,
};
dm2 = new DemandeDelegation()
{
DateDemande = DateTime.Now,
Ep = epEnCours4,
IdReferent = new Guid("d4fc247b-015a-44d6-8f3e-a52f0902d2bf"),
EtatDemande = EtatDemande.EnAttente,
RaisonDemande = "Raison quelconque 2"
};
epEnCours4.DemandeDelegation = dm2;
epContext.Ep.Add(epEnCours4);
epEnCours5 = new Ep()
@ -270,6 +289,15 @@ namespace EPAServeur.Context
Obligatoire = true,
};
epContext.Ep.Add(epEnCours8);
dm3 = new DemandeDelegation()
{
DateDemande = DateTime.Now,
Ep = epEnCours8,
IdReferent = new Guid("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d"),
EtatDemande = EtatDemande.EnAttente,
RaisonDemande = "Raison quelconque 3"
};
epEnCours8.DemandeDelegation = dm3;
epEnCours9 = new Ep()
{
@ -422,7 +450,7 @@ namespace EPAServeur.Context
epSigne7.CommentairesAssistant = new List<CommentaireAssistant>();
epSigne7.CommentairesAssistant.Add(ca3);
epContext.Ep.Add(epSigne7);
epSigne8 = new Ep()
{
DateDisponibilite = new DateTime(2020, 2, 13),

@ -173,7 +173,7 @@ namespace IO.Swagger.DTO
/// Gets or Sets DemandesDelegation
/// </summary>
[DataMember(Name="demandesDelegation")]
public List<DemandeDelegationDTO> DemandesDelegation { get; set; }
public DemandeDelegationDTO DemandesDelegation { get; set; }
/// <summary>
/// Gets or Sets DemandeEPI
@ -371,7 +371,7 @@ namespace IO.Swagger.DTO
(
DemandesDelegation == other.DemandesDelegation ||
DemandesDelegation != null &&
DemandesDelegation.SequenceEqual(other.DemandesDelegation)
DemandesDelegation.Equals(other.DemandesDelegation)
) &&
(
DemandeEPI == other.DemandeEPI ||

@ -75,9 +75,9 @@ namespace EPAServeur.IServices
List<EngagementDTO> GetEngagementDTOs(List<Engagement> engagements);
List<ParticipationEPDTO> GetParticipantsDTO(List<ParticipationEP> participants, IEnumerable<CollaborateurDTO> collaborateurDTOs);
List<CommentaireAssistantDTO> GetCommentaireAssistant(List<CommentaireAssistant> commentaireAssistant, IEnumerable<CollaborateurDTO> collaborateurDTOs);
DemandeDelegationDTO GetDemandeDelegationDTO(DemandeDelegation demandeDelegation, IEnumerable<CollaborateurDTO> collaborateurDTOs);
DemandeEPIDTO GetDemandeEPIDTO(DemandeEPI demande, IEnumerable<CollaborateurDTO> collaborateurDTOs);
AugmentationSalaireDTO GetAugmentationSalaireDTO(AugmentationSalaire augmentation);
DemandeDelegationDTO GetDemandeDelegationDTO(DemandeDelegation demandeDelegation, IEnumerable<CollaborateurDTO> collaborateurDTOs);
RDVEntretienDTO GetRDVEntretienDTO(RdvEntretien rdvEntretien);
TypeEntretienDTO GetEntretienDTO(ChoixTypeEntretien choixTypeEntretien);
DemandeFormationDTO GetDemandeFormationDTOEP(DemandeFormation demandeFormation);

@ -30,6 +30,7 @@ namespace EPAServeur.Services
.Include(ep => ep.Engagements)
.Include(ep => ep.Participants)
.Include(ep => ep.CommentairesAssistant)
.Include(ep => ep.DemandeDelegation)
.FirstOrDefaultAsync(ep => ep.IdEP.Equals(id));
if (ep == null)
throw new EpNotFoundException();
@ -43,7 +44,8 @@ namespace EPAServeur.Services
guids.AddRange(ep.Participants.SelectMany(p => new[] { (Guid?)p.IdParticipant }));
if (ep.CommentairesAssistant != null && ep.CommentairesAssistant.Any())
guids.AddRange(ep.CommentairesAssistant.SelectMany(p => new[] { (Guid?)p.IdAssistant }));
if (ep.DemandeDelegation != null)
guids.Add(ep.DemandeDelegation.IdReferent);
IEnumerable<CollaborateurDTO> collaborateurDTOs = await collaborateurService.GetCollaborateurDTOsAsync(guids);

@ -63,7 +63,8 @@ namespace EPAServeur.Services
Cv = ep.CV,
Engagements = GetEngagementDTOs(ep.Engagements),
Participants = GetParticipantsDTO(ep.Participants, collaborateurDTOs),
CommentairesAssistant = GetCommentaireAssistant(ep.CommentairesAssistant, collaborateurDTOs)
CommentairesAssistant = GetCommentaireAssistant(ep.CommentairesAssistant, collaborateurDTOs),
DemandesDelegation = GetDemandeDelegationDTO(ep.DemandeDelegation, collaborateurDTOs),
};
}
@ -260,7 +261,19 @@ namespace EPAServeur.Services
/// <returns>La demande de délégation transformé en DTO</returns>
public DemandeDelegationDTO GetDemandeDelegationDTO(DemandeDelegation demandeDelegation, IEnumerable<CollaborateurDTO> collaborateurDTOs)
{
throw new NotImplementedException();
if (demandeDelegation == null)
return null;
DemandeDelegationDTO demandeDelegationDTO = new DemandeDelegationDTO()
{
DateDemande = demandeDelegation.DateDemande,
DateReponse = demandeDelegation.DateReponse,
EtatDemande = demandeDelegation.EtatDemande,
Id = demandeDelegation.IdDemandeDelegation,
RaisonDemande = demandeDelegation.RaisonDemande,
RaisonRefus = demandeDelegation.RaisonRefus,
Referent = collaborateurDTOs.FirstOrDefault(c => c.Id.Equals(demandeDelegation.IdReferent))
};
return demandeDelegationDTO.Referent != null ? demandeDelegationDTO : null;
}
/// <summary>
@ -577,9 +590,7 @@ namespace EPAServeur.Services
});
}
}
if (participantsDTO.Any())
return participantsDTO;
return null;
return participantsDTO.Any() ? participantsDTO : null;
}
/// <summary>

Loading…
Cancel
Save