diff --git a/EPAServeur/IServices/ITransformDTO.cs b/EPAServeur/IServices/ITransformDTO.cs index 2565734..b39721d 100644 --- a/EPAServeur/IServices/ITransformDTO.cs +++ b/EPAServeur/IServices/ITransformDTO.cs @@ -15,6 +15,7 @@ namespace EPAServeur.IServices AgenceDTO GetAgenceDTO(Agence agence); BusinessUnitDTO GetBusinessUnitDTO(BU businessUnit); CollaborateurDTO GetCollaborateurDTO(ParticipationFormation participationFormation, IEnumerable collaborateurDTOs); + CollaborateurDTO GetCollaborateurDTO(DemandeFormation demandeFormation, IEnumerable collaborateurDTOs); // DemandeDelegation DemandeDelegationDTO GetDemandeDelegationDTO(DemandeDelegation demande, CollaborateurDTO referent, IEnumerable collaborateurs); @@ -36,6 +37,7 @@ namespace EPAServeur.IServices ModeFormationDTO GetModeFormationDTO(ModeFormation modeFormation); TypeFormationDTO GetTypeFormationDTO(TypeFormation typeFormation); Formation SetFormation(Formation formation, FormationDTO formationDTO); + Formation GetFormation(FormationDetailsDTO formationDetailsDTO); OrigineFormation GetOrigineFormation(OrigineFormationDTO origineFormationDTO); StatutFormation GetStatutFormation(StatutFormationDTO statutFormationDTO); ModeFormation GetModeFormation(ModeFormationDTO modeFormationDTO); @@ -55,5 +57,11 @@ namespace EPAServeur.IServices Saisie GetSaisie(SaisieDTO saisieDTO); Champ GetChamp(ChampDTO champDTO); + // DemandeFormation + DemandeFormationDTO GetDemandeFormationDTO(DemandeFormation demandeFormation, IEnumerable collaborateurDTOs); + DemandeFormation SetDemandeFormationWithoutParticipationFormationAndEp(DemandeFormation demandeFormation, DemandeFormationDTO demandeFormationDTO); + OrigineDemandeFormationDTO GetOrigineDemandeFormationDTO(OrigineDemande origineDemande); + OrigineDemande GetOrigineDemandeFormation(OrigineDemandeFormationDTO origineDemandeDTO); + } } diff --git a/EPAServeur/Services/TransformDTO.cs b/EPAServeur/Services/TransformDTO.cs index 75a5bf8..c7d7d0c 100644 --- a/EPAServeur/Services/TransformDTO.cs +++ b/EPAServeur/Services/TransformDTO.cs @@ -165,7 +165,25 @@ namespace EPAServeur.Services return collaborateurDTOs.FirstOrDefault(collaborateurDTO => collaborateurDTO.Id == participationFormation.DemandeFormation.Ep.IdCollaborateur); } - + /// + /// Récupérer le collaborateur qui a fait une demande de formation. + /// + /// + /// + /// + public CollaborateurDTO GetCollaborateurDTO(DemandeFormation demandeFormation, IEnumerable collaborateurDTOs) + { + if (demandeFormation == null) + return null; + + if (collaborateurDTOs == null || !collaborateurDTOs.Any()) + return null; + + return collaborateurDTOs.FirstOrDefault(collaborateurDTO => collaborateurDTO.Id == demandeFormation.Ep.IdCollaborateur); + } + + + /// /// Transformer un objet DemandeDelegation en objet DemandeDelegationDTO. /// L'objet CollaborateurDTO est utilisé pour alimenter la propriété Referent de l'objet DemandeDelegationDTO. @@ -485,7 +503,66 @@ namespace EPAServeur.Services return participationFormationDTOs; } - + // + /// Récuperer un objet OrigineDemandeFormationDTO en fonction d'un objet OrigineDemande + /// + /// + /// + public OrigineDemandeFormationDTO GetOrigineDemandeFormationDTO(OrigineDemande origineDemande) + { + if (origineDemande == null) + return null; + + OrigineDemandeFormationDTO origineDemandeFormationDTO = new OrigineDemandeFormationDTO() + { + Id = origineDemande.IdOrigineDemande, + Libelle = origineDemande.Libelle + }; + + return origineDemandeFormationDTO; + } + + /// + /// Récuperer un objet DemandeFormationDTO en fonction d'un objet DemandeFormation et d'une liste de CollaborateurDTO + /// + /// + /// + public DemandeFormationDTO GetDemandeFormationDTO(DemandeFormation demandeFormation, IEnumerable collaborateurDTOs) + { + if (demandeFormation == null) + return null; + + if (collaborateurDTOs == null || !collaborateurDTOs.Any()) + return null; + + Formation formation; + + if (demandeFormation.ParticipationFormation != null) + formation = demandeFormation.ParticipationFormation.Formation; + else + formation = null; + + DemandeFormationDTO demandeFormationDTO = new DemandeFormationDTO() + { + Id = demandeFormation.IdDemandeFormation, + Libelle = demandeFormation.Libelle, + Description = demandeFormation.Description, + DemandeRH = demandeFormation.DemandeRH, + DateDemande = demandeFormation.DateDemande, + EtatDemande = demandeFormation.Etat, + CommentaireRefus = demandeFormation.CommentaireRefus, + DateDerniereReponse = demandeFormation.DateDerniereReponse, + Origine = GetOrigineDemandeFormationDTO(demandeFormation.OrigineDemande), + Collaborateur = GetCollaborateurDTO(demandeFormation, collaborateurDTOs), + Ep = GetEpInformationDTO(demandeFormation.Ep, collaborateurDTOs), + Formation = GetFormationDetailsDTO(formation) + }; + + return demandeFormationDTO; + } + + + /// /// Transformer un objet SaisieDTO en objet Saisie. /// @@ -653,6 +730,49 @@ namespace EPAServeur.Services return details; } + // + /// Récupérer un objet OrigineDemande en fonction d'un objet OrigineDemandeFormationDTO + /// + /// + /// + public OrigineDemande GetOrigineDemandeFormation(OrigineDemandeFormationDTO origineDemandeDTO) + { + if (origineDemandeDTO == null) + return null; + + OrigineDemande origineDemandeFormation = new OrigineDemande() + { + IdOrigineDemande = origineDemandeDTO.Id.Value, + Libelle = origineDemandeDTO.Libelle + }; + + return origineDemandeFormation; + } + + /// + /// Mettre à jour un objet DemandeFormation en fonction d'un objet DemandeFormationDTO. + /// + /// Les propriétés ParticipationFormation et Ep ne sont pas mise à jour. + /// + /// + /// + public DemandeFormation SetDemandeFormationWithoutParticipationFormationAndEp(DemandeFormation demandeFormation, DemandeFormationDTO demandeFormationDTO) + { + if (demandeFormation == null || demandeFormationDTO == null) + return null; + + demandeFormation.Libelle = demandeFormationDTO.Libelle; + demandeFormation.Description = demandeFormationDTO.Description; + demandeFormation.DemandeRH = demandeFormationDTO.DemandeRH.Value; + demandeFormation.DateDemande = demandeFormationDTO.DateDemande.Value; + demandeFormation.Etat = demandeFormationDTO.EtatDemande; + demandeFormation.CommentaireRefus = demandeFormationDTO.CommentaireRefus; + demandeFormation.DateDerniereReponse = demandeFormationDTO.DateDerniereReponse; + demandeFormation.OrigineDemande = GetOrigineDemandeFormation(demandeFormationDTO.Origine); + + return demandeFormation; + } + /// /// Mettre à jour un objet Formation en fonction d'un objet FormationDTO. /// @@ -664,6 +784,9 @@ namespace EPAServeur.Services if (formation == null || formationDTO == null) return null; + if (formationDTO.Id.HasValue) + formation.IdFormation = formationDTO.Id.Value; + formation.Intitule = formationDTO.Intitule; formation.IdAgence = formationDTO.IdAgence.Value; formation.DateDebut = formationDTO.DateDebut.Value; @@ -681,6 +804,34 @@ namespace EPAServeur.Services return formation; } + /// + /// Récupérer un objet Formation en fonction d'un objet FormationDetailsDTO. + /// + /// + /// + public Formation GetFormation(FormationDetailsDTO formationDetailsDTO) + { + if (formationDetailsDTO == null) + return null; + + Formation formation = new Formation + { + Intitule = formationDetailsDTO.Intitule, + DateDebut = formationDetailsDTO.DateDebut.Value, + DateFin = formationDetailsDTO.DateFin.Value, + Organisme = formationDetailsDTO.Organisme, + EstCertifiee = formationDetailsDTO.EstCertifiee.Value, + //EstRealisee = formationDTO.EstRealisee.Value, + Origine = GetOrigineFormation(formationDetailsDTO.Origine), + Statut = GetStatutFormation(formationDetailsDTO.Statut), + }; + + if (formationDetailsDTO.Id.HasValue) + formation.IdFormation = formationDetailsDTO.Id.Value; + + return formation; + } + /// /// Mettre à jour la réponse d'un objet Engagement en fonction d'un objet EngagementDTO. ///