From 644d473ce713667b52910ef129653dbd99f5b9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yana=C3=ABl=20GRETTE?= Date: Wed, 17 Mar 2021 15:01:12 +0100 Subject: [PATCH] =?UTF-8?q?Impl=C3=A9mentation=20de=20la=20r=C3=A9cup?= =?UTF-8?q?=C3=A9ration=20des=20demandes=20de=20formation=20avec=20un=20EP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/EpDetailsServiceTests.cs | 31 ++++++++----- EPAServeur/Context/DataSeeder.cs | 45 ++++++++++++++++++- EPAServeur/IServices/ITransformDTO.cs | 6 +-- EPAServeur/Properties/launchSettings.json | 2 +- EPAServeur/Services/EpDetailsService.cs | 2 + EPAServeur/Services/TransformDTO.cs | 26 +++++++++-- 6 files changed, 91 insertions(+), 21 deletions(-) diff --git a/EPAServeur.Tests/Services/EpDetailsServiceTests.cs b/EPAServeur.Tests/Services/EpDetailsServiceTests.cs index 361c8a9..118621f 100644 --- a/EPAServeur.Tests/Services/EpDetailsServiceTests.cs +++ b/EPAServeur.Tests/Services/EpDetailsServiceTests.cs @@ -270,18 +270,27 @@ namespace EPAServeur.Tests.Services #endregion #region Récupérer EP avec demandes de formation + [TestCase(1,0)] + [TestCase(2,0)] + [TestCase(3,1)] + [TestCase(12,3)] + [TestCase(16,0)] + public async Task GetEp_GetpDemandesFormation(long idEp, int count) + { + IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService); + EpDTO epDTO = await epDetailsService.GetEp(idEp); + Assert.IsNotNull(epDTO); + if(count == 0) + { + Assert.IsNull(epDTO.DemandesFormation); + } + else + { + Assert.IsNotNull(epDTO.DemandesFormation); + Assert.AreEqual(epDTO.DemandesFormation.Count, count); + } + } #endregion - - - - - - - #region - #endregion - - #region - #endregion } } diff --git a/EPAServeur/Context/DataSeeder.cs b/EPAServeur/Context/DataSeeder.cs index 581fd3b..e62468a 100644 --- a/EPAServeur/Context/DataSeeder.cs +++ b/EPAServeur/Context/DataSeeder.cs @@ -106,6 +106,8 @@ namespace EPAServeur.Context DemandeEPI demandeEPI1, demandeEPI2, demandeEPI3; + DemandeFormation demandeF1, demandeF2, demandeF3, demandeF4; + //Ep en cours Ep epEnCours1, epEnCours2, epEnCours3, epEnCours4, epEnCours5, epEnCours6, epEnCours7, epEnCours8, epEnCours9; @@ -253,8 +255,16 @@ namespace EPAServeur.Context epEnCours3.Objectifs = new List() { objectif1, objectif2, objectif3 }; epEnCours3.ObjectifsPrecedents = new List() { objectifPrecedent1, objectifPrecedent2, objectifPrecedent3 }; - - + demandeF1 = new DemandeFormation() + { + DateDemande = new DateTime(), + Description = "Description", + DemandeRH = false, + Libelle = "Libellé", + Etat = EtatDemande.EnAttente, + Ep = epEnCours3, + }; + epEnCours3.DemandesFormation = new List() { demandeF1 }; epContext.Ep.Add(epEnCours3); @@ -568,6 +578,37 @@ namespace EPAServeur.Context }; epSigne3.RdvEntretien = rdv3; + + demandeF2 = new DemandeFormation() + { + DateDemande = new DateTime(), + Description = "Description 2", + DemandeRH = false, + Libelle = "Libellé 2", + Etat = EtatDemande.EnAttente, + Ep = epSigne3, + }; + + demandeF3 = new DemandeFormation() + { + DateDemande = new DateTime(), + Description = "Description 3", + DemandeRH = false, + Libelle = "Libellé 3", + Etat = EtatDemande.EnAttente, + Ep = epSigne3, + }; + + demandeF4 = new DemandeFormation() + { + DateDemande = new DateTime(), + Description = "Description 4", + DemandeRH = true, + Libelle = "Libellé 4", + Etat = EtatDemande.EnAttente, + Ep = epSigne3, + }; + epSigne3.DemandesFormation = new List() { demandeF2, demandeF3, demandeF4 }; epContext.Ep.Add(epSigne3); diff --git a/EPAServeur/IServices/ITransformDTO.cs b/EPAServeur/IServices/ITransformDTO.cs index 6b59dba..463c655 100644 --- a/EPAServeur/IServices/ITransformDTO.cs +++ b/EPAServeur/IServices/ITransformDTO.cs @@ -79,6 +79,8 @@ namespace EPAServeur.IServices List GetCommentaireAssistant(List commentaireAssistant, IEnumerable collaborateurDTOs); DemandeDelegationDTO GetDemandeDelegationDTO(DemandeDelegation demandeDelegation, IEnumerable collaborateurDTOs); DemandeEPIDTO GetDemandeEPIDTO(DemandeEPI demande, IEnumerable collaborateurDTOs); + DemandeFormationDTO GetDemandeFormationDTO(DemandeFormation demandeFormation); + List GetDemandeFormationDTOs(List demandes); AugmentationSalaireDTO GetAugmentationSalaireDTO(AugmentationSalaire augmentation); RDVEntretienDTO GetRDVEntretienDTO(RdvEntretien rdvEntretien); TypeEntretienDTO GetTypeEntretienDTO(TypeEntretien typeEntretien); @@ -87,10 +89,6 @@ namespace EPAServeur.IServices DocumentDTO GetDocumentDTO(Document document); List GetObjectifDTOs(List objectifs); List GetObjectifPrecedentDTO(List objectifsPrecedents); - - - - #endregion #region Demande Formation diff --git a/EPAServeur/Properties/launchSettings.json b/EPAServeur/Properties/launchSettings.json index 0c92275..cc014d0 100644 --- a/EPAServeur/Properties/launchSettings.json +++ b/EPAServeur/Properties/launchSettings.json @@ -11,7 +11,7 @@ "profiles": { "IIS Express": { "commandName": "IISExpress", - "launchBrowser": true, + "launchBrowser": false, "launchUrl": "api/", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/EPAServeur/Services/EpDetailsService.cs b/EPAServeur/Services/EpDetailsService.cs index 5eb2ff9..53c5370 100644 --- a/EPAServeur/Services/EpDetailsService.cs +++ b/EPAServeur/Services/EpDetailsService.cs @@ -37,6 +37,7 @@ namespace EPAServeur.Services .Include(ep => ep.Objectifs) .Include(ep => ep.ObjectifsPrecedents) .Include(ep => ep.DemandeEPI) + .Include(ep => ep.DemandesFormation) .FirstOrDefaultAsync(ep => ep.IdEP.Equals(id)); if (ep == null) throw new EpNotFoundException(); @@ -57,6 +58,7 @@ namespace EPAServeur.Services if (ep.DemandeEPI != null && ep.DemandeEPI.IdReferent != null) guids.Add(ep.DemandeEPI.IdReferent); + IEnumerable collaborateurDTOs = await collaborateurService.GetCollaborateurDTOsAsync(guids); EpDTO epDTO = transformDTO.EpToEpDetails(ep, collaborateurDTOs); diff --git a/EPAServeur/Services/TransformDTO.cs b/EPAServeur/Services/TransformDTO.cs index 93d743d..0f90d9b 100644 --- a/EPAServeur/Services/TransformDTO.cs +++ b/EPAServeur/Services/TransformDTO.cs @@ -67,7 +67,9 @@ namespace EPAServeur.Services ChoixTypeEntretien = GetTypeEntretienDTOs(ep.ChoixTypeEntretien), Objectifs = GetObjectifDTOs(ep.Objectifs), ObjectifsPrecedent = GetObjectifPrecedentDTO(ep.ObjectifsPrecedents), - DemandeEPI = GetDemandeEPIDTO(ep.DemandeEPI, collaborateurDTOs) + DemandeEPI = GetDemandeEPIDTO(ep.DemandeEPI, collaborateurDTOs), + DemandesFormation = GetDemandeFormationDTOs(ep.DemandesFormation) + }; } @@ -319,9 +321,20 @@ namespace EPAServeur.Services } - public DemandeFormationDTO GetDemandeFormationDTOEP(DemandeFormation demandeFormation) + public DemandeFormationDTO GetDemandeFormationDTO(DemandeFormation demandeFormation) { - throw new NotImplementedException(); + if (demandeFormation == null) + return null; + return new DemandeFormationDTO() + { + CommentaireRefus = demandeFormation.CommentaireRefus, + DemandeRH = demandeFormation.DemandeRH, + Libelle = demandeFormation.Libelle, + EtatDemande = demandeFormation.Etat, + Description = demandeFormation.Description, + DateDemande = demandeFormation.DateDemande, + + }; } @@ -1073,5 +1086,12 @@ namespace EPAServeur.Services Commentaire = o.Commentaire }).ToList(); } + + public List GetDemandeFormationDTOs(List demandes) + { + if (demandes == null || !demandes.Any()) + return null; + return demandes.Select(d => GetDemandeFormationDTO(d)).ToList(); + } } }