using EPAServeur.Context; using EPAServeur.Exceptions; using EPAServeur.IServices; using EPAServeur.Models.EP; using EPAServeur.Models.Formation; using IO.Swagger.DTO; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace EPAServeur.Services { public class FormationService : IFormationService { #region Variables /// /// Accès et gestion de la base de données /// private readonly EpContext epContext; /// /// Accès et service collaborateur /// private readonly ICollaborateurService collaborateurService; /// /// Nombre d'éléments min à afficher par page /// private readonly int minParPage = 5; /// /// Nom d'éléments max à affichar par page /// private readonly int maxParPage = 100; /// /// Nombre d'éléments à afficher par défaut par page /// private readonly int defaultParPage = 15; /// /// Numéro de page min à afficher par défaut /// private readonly int defaultNumPage = 1; /// /// Ordonnancement par défaut /// private readonly bool defaultAsc = true; #endregion #region Contructeurs /// /// Constructeur de la classe FormationService /// /// public FormationService(EpContext _epContext, ICollaborateurService _collaborateurService) { epContext = _epContext; collaborateurService = _collaborateurService; } #endregion #region Méthodes Service /// /// Récupérer une formation par son id de manière asynchrone /// /// /// public async Task GetFormationByIdAsync(long idFormation) { Formation formation = await epContext.Formation.Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation) .Include(formation => formation.ParticipationsFormation) .ThenInclude(participation => participation.DemandeFormation) .ThenInclude(demande => demande.Ep) .FirstOrDefaultAsync(formation => formation.IdFormation == idFormation); if (formation == null) throw new FormationNotFoundException(string.Format("Aucune formation trouvée avec l'id suivant: {0}.", idFormation)); if (formation.ParticipationsFormation.Count > 0) { IEnumerable collaborateurDTOs = await GetCollaborateurDTOs(formation.ParticipationsFormation); return GetFormationDTO(formation, collaborateurDTOs); } else { return GetFormationDTO(formation); } } /// /// Récupérer la liste des formations de manière asynchrone /// /// Préciser si les données sont dans l'ordre (true) ou dans l'ordre inverse (false) /// Numéro de la page du tableau qui affiche les données /// Nombre d'éléments affiché sur chaque page du tableau /// id de l'agence à laquelle sont rattachées les données à récupérer /// Texte permettant d'identifier l'objet rechercher /// Colonne du tableau sur lequel le tri s'effectue /// public async Task> GetFormationsAsync(long? idAgence, List idStatuts, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) { IQueryable query; IEnumerable formations; IEnumerable formationDTOs; query = epContext.Formation .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation) .Include(formation => formation.ParticipationsFormation); query = IdStatutsFilter(query, idStatuts); query = IdAgenceFilter(query, idAgence); query = IntituleFilter(query, texte); query = DateFilter(query, dateDebut, dateFin); query = OrderByColumn(query, asc, tri); query = SkipAndTake(query, parPage, numPage); formations = await query.ToListAsync(); formationDTOs = formations.Select(formation => GetFormationDetailsDTO(formation)); return formationDTOs; } /// /// Récupérer le nombre total de formations de manière asynchrone /// /// Numéro de la page du tableau qui affiche les données /// Nombre d'éléments affiché sur chaque page du tableau /// id de l'agence à laquelle sont rattachées les données à récupérer /// Texte permettant d'identifier l'objet rechercher /// public async Task GetFormationsCountAsync(long? idAgence, List idStatuts, string texte, DateTime? dateDebut, DateTime? dateFin) { IQueryable query; long count; query = epContext.Formation .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation) .Include(formation => formation.ParticipationsFormation); query = IntituleFilter(query, texte); query = IdStatutsFilter(query, idStatuts); query = IdAgenceFilter(query, idAgence); query = DateFilter(query, dateDebut, dateFin); count = await query.CountAsync(); return count; } /// /// Récupérer les modes de formation de manière asynchrone /// /// public async Task> GetModesFormationAsync() { IEnumerable modeFormations; IEnumerable modeFormationDTOs; modeFormations = await epContext.ModeFormation.ToListAsync(); modeFormationDTOs = modeFormations.Select(modeFormation => GetModeFormationDTO(modeFormation)); return modeFormationDTOs; } /// /// Récupérer les origines de formation de manière asynchrone /// /// public async Task> GetOriginesFormationAsync() { IEnumerable origineFormations; IEnumerable origineFormationDTOs; origineFormations = await epContext.OrigineFormation.ToListAsync(); origineFormationDTOs = origineFormations.Select(origineFormation => GetOrigineFormationDTO(origineFormation)); return origineFormationDTOs; } /// /// Récupérer les statuts de formation de manière asynchrone /// /// public async Task> GetStatutsFormationAsync() { IEnumerable statutFormations; IEnumerable statutFormationDTOs; statutFormations = await epContext.StatutFormation.ToListAsync(); statutFormationDTOs = statutFormations.Select(statutFormation => GetStatutFormationDTO(statutFormation)); return statutFormationDTOs; } /// /// Récupérer les types de formation de manière asynchrone /// /// public async Task> GetTypesFormationAsync() { IEnumerable typeFormations; IEnumerable typeFormationDTOs; typeFormations = await epContext.TypeFormation.ToListAsync(); typeFormationDTOs = typeFormations.Select(typeFormation => GetTypeFormationDTO(typeFormation)); return typeFormationDTOs; } /// /// Ajouter une formation de manière asynchrone /// /// /// public async Task AddFormationAsync(FormationDTO formationDTO) { IsFormationValide(formationDTO); Formation formation = new Formation(); formation = SetFormation(formation, formationDTO); epContext.StatutFormation.Attach(formation.Statut); epContext.OrigineFormation.Attach(formation.Origine); epContext.ModeFormation.Attach(formation.ModeFormation); epContext.TypeFormation.Attach(formation.TypeFormation); epContext.Add(formation); await epContext.SaveChangesAsync(); return GetFormationDTO(formation); } /// /// Modifier une formation de manière asynchrone /// /// /// /// public async Task UpdateFormationAsync(long idFormation, FormationDTO formationDTO) { IsFormationValide(formationDTO); if (!formationDTO.Id.HasValue || formationDTO.Id.Value != idFormation) throw new FormationIncompatibleIdException("L'id de la formation a mettre à jour et la formation a mettre à jour sont incompatble."); Formation formation = await epContext.Formation.Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation) .Include(formation => formation.ParticipationsFormation) .ThenInclude(participation => participation.DemandeFormation) .ThenInclude(demande => demande.Ep) .FirstOrDefaultAsync(formation => formation.IdFormation == idFormation); if (formation == null) throw new FormationNotFoundException(string.Format("Aucune formation trouvée avec l'id suivant: {0}.", idFormation)); formation = SetFormation(formation, formationDTO); await epContext.SaveChangesAsync(); return GetFormationDTO(formation); } /// /// Supprimer une formation de manière asynchrone /// /// /// public async Task DeleteFormationByIdAsync(long idFormation) { Formation formation = await epContext.Formation.Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation) .Include(formation => formation.ParticipationsFormation) .ThenInclude(participation => participation.DemandeFormation) .ThenInclude(demande => demande.Ep) .FirstOrDefaultAsync(formation => formation.IdFormation == idFormation); if (formation == null) throw new FormationNotFoundException(string.Format("Aucune formation trouvée avec l'id suivant: {0}.", idFormation)); epContext.Remove(formation); await epContext.SaveChangesAsync(); return GetFormationDTO(formation); } #endregion #region Méthodes Privée /// /// Vérifier si un objet FormationDTO est valide pour ajout ou mise à jour /// /// Un objet FormationDTO est valide si aucune de ses propriétés n'est à null,si la date de début de la formation est inférieur à la date de fin et si le statut, l'origine,le mode et le type sont présents dans la base de données /// /// true si l'objet est valide, false sinon private void IsFormationValide(FormationDTO formation) { // Vérifier que la formation n'est pas null if (formation == null) throw new FormationInvalidException("Aucune formation n'a été reçue"); // Vérfier que la formation a bien un statut de formation if (formation.Statut == null || !formation.Statut.Id.HasValue) throw new FormationInvalidException("Impossible d'enregistrer une formation sans statut de formation."); // Vérfier que la formation a bien un mode de formation if (formation.Mode == null || !formation.Mode.Id.HasValue) throw new FormationInvalidException("Impossible d'enregistrer une formation sans mode de formation."); // Vérfier que la formation a bien une origine de formation if (formation.Origine == null || !formation.Origine.Id.HasValue) throw new FormationInvalidException("Impossible d'enregistrer une formation sans origine de formation."); // Vérfier que la formation a bien un type de formation if (formation.Type == null || !formation.Type.Id.HasValue) throw new FormationInvalidException("Impossible d'enregistrer une formation sans type de formation."); // Vérfier que la formation a bien une agence if (!formation.IdAgence.HasValue || formation.IdAgence == 0) throw new FormationInvalidException("Impossible d'enregistrer une formation sans mode de formation."); // Vérifier que la formation a bien un intitulé if (string.IsNullOrWhiteSpace(formation.Intitule)) throw new FormationInvalidException("L'intitulé de la formation doit contenir au moins 1 caractère."); // Vérifier que la formation a bien un organisme if (string.IsNullOrWhiteSpace(formation.Organisme)) throw new FormationInvalidException("L'organisme de la formation doit contenir au moins 1 caractère."); // Vérifier que la formation a bien une date de début if (!formation.DateDebut.HasValue) throw new FormationInvalidException("Impossible d'enregistrer une formation sans date de début de formation."); // Vérifier que la formation a bien une date de fin if (!formation.DateFin.HasValue) throw new FormationInvalidException("Impossible d'enregistrer une formation sans date de fin de formation."); // Vérifier que la formation a bien une date de début inférieure à la date de fin if (formation.DateDebut.Value > formation.DateFin.Value) throw new FormationInvalidException("La date de début de la formation est supérieure à la date de fin."); // Vérfier que le statut de la formation est présent dans la BDD if (!epContext.StatutFormation.Any(statut => statut.IdStatutFormation == formation.Statut.Id.Value && statut.Libelle == formation.Statut.Libelle)) throw new FormationInvalidException("Le statut de la formation n'existe pas."); // Vérfier que le mode de la formation est présent dans la BDD if (!epContext.ModeFormation.Any(mode => mode.IdModeFormation == formation.Mode.Id.Value && mode.Libelle == formation.Mode.Libelle)) throw new FormationInvalidException("Le mode de la formation n'existe pas."); // Vérfier que l'orgine de la formation est présente dans la BDD if (!epContext.OrigineFormation.Any(origine => origine.IdOrigineFormation == formation.Origine.Id.Value && origine.Libelle == formation.Origine.Libelle)) throw new FormationInvalidException("L'origine de la formation n'existe pas."); // Vérfier que le type de la formation est présent dans la BDD if (!epContext.TypeFormation.Any(type => type.IdTypeFormation == formation.Type.Id.Value && type.Libelle == formation.Type.Libelle)) throw new FormationInvalidException("Le type de la formation n'existe pas."); } /// /// Ajouter un ordonnancement croissant ou décroissant sur colonne /// /// /// /// private IQueryable OrderByColumn(IQueryable query, bool? asc, string columnName) { if (!asc.HasValue) asc = defaultAsc; if (string.IsNullOrWhiteSpace(columnName)) { if (asc.Value) return query.OrderBy(p => p.Intitule); else return query.OrderByDescending(p => p.Intitule); } switch (columnName.ToLower()) { case "intitule": if (asc.Value) return query.OrderBy(p => p.Intitule); else return query.OrderByDescending(p => p.Intitule); case "statut": if (asc.Value) return query.OrderBy(p => p.Statut.Libelle); else return query.OrderByDescending(p => p.Statut.Libelle); case "origine": if (asc.Value) return query.OrderBy(p => p.Origine.Libelle); else return query.OrderByDescending(p => p.Origine.Libelle); case "date": if (asc.Value) return query.OrderBy(p => p.DateDebut); else return query.OrderByDescending(p => p.DateDebut); case "certification": if (asc.Value) return query.OrderBy(p => p.EstCertifiee); else return query.OrderByDescending(p => p.EstCertifiee); case "participants": if (asc.Value) return query.OrderBy(p => p.ParticipationsFormation.Count); else return query.OrderByDescending(p => p.ParticipationsFormation.Count); default: if (asc.Value) return query.OrderBy(p => p.Intitule); else return query.OrderByDescending(p => p.Intitule); } } /// /// Ajouter un filtre pour récupérer les formations en fonction de plusieurs identifiants de statut de formation /// /// /// /// private IQueryable IdStatutsFilter(IQueryable query, List idStatuts) { if (idStatuts != null && idStatuts.Count > 0 && idStatuts.First().HasValue) return query.Where(formation => idStatuts.Contains(formation.Statut.IdStatutFormation)); else return query; } /// /// Ajouter un filtre pour récupérer les formations en fonction de l'identifiant d'une agence /// /// /// /// private IQueryable IdAgenceFilter(IQueryable query, long? idAgence) { if (idAgence != null) return query.Where(formation => formation.IdAgence == idAgence); else return query; } /// /// Ajouter un filtre pour récupérer les formations en fonction d'un intitulé /// /// /// /// private IQueryable IntituleFilter(IQueryable query, string intitule) { if (!string.IsNullOrWhiteSpace(intitule)) return query.Where(formation => formation.Intitule.ToLower().Contains(intitule.ToLower())); else return query; } /// /// Ajouter un filtre pour récupérer les formations en fonction d'un intervalle de date /// /// /// /// /// private IQueryable DateFilter(IQueryable query, DateTime? dateDebut, DateTime? dateFin) { if (dateDebut.HasValue && dateFin.HasValue) return query.Where(formation => formation.DateDebut >= dateDebut.Value && formation.DateFin <= dateFin.Value.AddDays(1)); else if (!dateDebut.HasValue && dateFin.HasValue) return query.Where(formation => formation.DateFin <= dateFin.Value.AddDays(1)); else if (dateDebut.HasValue && !dateFin.HasValue) return query.Where(formation => formation.DateDebut >= dateDebut.Value); else return query; } /// /// Ajouter une pagination /// /// /// /// /// private IQueryable SkipAndTake(IQueryable query, int? parPage, int? numPage) { int skip, take; if (!parPage.HasValue || parPage.Value < minParPage || parPage.Value > maxParPage) parPage = defaultParPage; if (!numPage.HasValue || numPage.Value <= 0) numPage = defaultNumPage; skip = (numPage.Value - 1) * parPage.Value; take = parPage.Value; return query.Skip(skip).Take(take); } #region Object to DTO /// /// Récuperer un objet FormationDTO en fonction d'un objet Formation /// /// /// private FormationDTO GetFormationDTO(Formation formation) { if (formation == null) return null; FormationDTO formationDTO = new FormationDTO() { Id = formation.IdFormation, Intitule = formation.Intitule, IdAgence = formation.IdAgence, DateDebut = formation.DateDebut, DateFin = formation.DateFin, Heure = formation.Heure, Jour = formation.Jour, Organisme = formation.Organisme, EstCertifiee = formation.EstCertifiee, EstRealisee = formation.EstRealisee, Origine = GetOrigineFormationDTO(formation.Origine), Statut = GetStatutFormationDTO(formation.Statut), Mode = GetModeFormationDTO(formation.ModeFormation), Type = GetTypeFormationDTO(formation.TypeFormation), }; return formationDTO; } /// /// Récuperer un objet FormationDTO avec des participations en fonction d'un objet Formation et d'une liste de CollaborateurDTO /// /// /// private FormationDTO GetFormationDTO(Formation formation, IEnumerable collaborateurDTOs) { if (formation == null || collaborateurDTOs == null || !collaborateurDTOs.Any()) return null; FormationDTO formationDTO = new FormationDTO() { Id = formation.IdFormation, Intitule = formation.Intitule, IdAgence = formation.IdAgence, DateDebut = formation.DateDebut, DateFin = formation.DateFin, Heure = formation.Heure, Jour = formation.Jour, Organisme = formation.Organisme, EstCertifiee = formation.EstCertifiee, EstRealisee = formation.EstRealisee, Origine = GetOrigineFormationDTO(formation.Origine), Statut = GetStatutFormationDTO(formation.Statut), Mode = GetModeFormationDTO(formation.ModeFormation), Type = GetTypeFormationDTO(formation.TypeFormation), Participations = GetParticipationsFormationDTO(formation.ParticipationsFormation, collaborateurDTOs) }; return formationDTO; } /// /// Récuperer un objet FormationDetailsDTO en fonction d'un objet Formation /// /// /// private FormationDetailsDTO GetFormationDetailsDTO(Formation formation) { if (formation == null) return null; FormationDetailsDTO formationDTO = new FormationDetailsDTO() { Id = formation.IdFormation, Intitule = formation.Intitule, DateDebut = formation.DateDebut, DateFin = formation.DateFin, Organisme = formation.Organisme, EstCertifiee = formation.EstCertifiee, NbParticipations = formation.ParticipationsFormation.Count, Origine = GetOrigineFormationDTO(formation.Origine), Statut = GetStatutFormationDTO(formation.Statut), }; return formationDTO; } /// /// Récuperer un objet OrigineFormationDTO en fonction d'un objet OrigineFormation /// /// /// private OrigineFormationDTO GetOrigineFormationDTO(OrigineFormation origineFormation) { if (origineFormation == null) return null; OrigineFormationDTO origineFormationDTO = new OrigineFormationDTO() { Id = origineFormation.IdOrigineFormation, Libelle = origineFormation.Libelle }; return origineFormationDTO; } /// /// Récuperer un objet StatutFormationDTO en fonction d'un objet StatutFormation /// /// /// private StatutFormationDTO GetStatutFormationDTO(StatutFormation statutFormation) { if (statutFormation == null) return null; StatutFormationDTO statutFormationDTO = new StatutFormationDTO() { Id = statutFormation.IdStatutFormation, Libelle = statutFormation.Libelle }; return statutFormationDTO; } /// /// Récuperer un objet ModeFormationDTO en fonction d'un objet ModeFormation /// /// /// private ModeFormationDTO GetModeFormationDTO(ModeFormation modeFormation) { if (modeFormation == null) return null; ModeFormationDTO modeFormationDTO = new ModeFormationDTO() { Id = modeFormation.IdModeFormation, Libelle = modeFormation.Libelle }; return modeFormationDTO; } /// /// Récuperer un objet TypeFormationDTO en fonction d'un objet TypeFormation /// /// /// private TypeFormationDTO GetTypeFormationDTO(TypeFormation typeFormation) { if (typeFormation == null) return null; TypeFormationDTO typeFormationDTO = new TypeFormationDTO() { Id = typeFormation.IdTypeFormation, Libelle = typeFormation.Libelle }; return typeFormationDTO; } /// /// Récuperer une liste de CollaborateurDTO contenant les collaborateurs et les référents. Retourne null s'il n'y a aucune participation. /// /// /// private async Task> GetCollaborateurDTOs(List participationsFormation) { if (participationsFormation == null || participationsFormation.Count == 0) return null; List guids = participationsFormation.SelectMany(participationFormation => new[] { (Guid?)participationFormation.DemandeFormation.Ep.IdCollaborateur, participationFormation.DemandeFormation.Ep.IdReferent }).ToList(); return await collaborateurService.GetCollaborateurDTOsAsync(guids); ; } /// /// Récuperer une liste de ParticipationFormationDTO en fonction d'une liste de ParticipationFormation et d'une liste de CollaborateurDTO. Retourne null s'il n'y a aucune participation ou aucun collaborateur. /// /// /// private List GetParticipationsFormationDTO(List participationsFormation, IEnumerable collaborateurDTOs) { List participationFormationDTOs; if (participationsFormation == null || participationsFormation.Count == 0 || collaborateurDTOs == null || !collaborateurDTOs.Any()) return null; participationFormationDTOs = participationsFormation.Select(participationFormation => GetParticipationFormationDTO(participationFormation, collaborateurDTOs)) .OrderBy(participationFormation => participationFormation.Collaborateur.Nom) .ThenBy(participationFormation => participationFormation.Collaborateur.Prenom).ToList(); return participationFormationDTOs; } /// /// Récuperer un objet ParticipationFormationDTO en fonction d'un objet ParticipationFormation et d'une liste de CollaborateurDTO /// /// /// private ParticipationFormationDTO GetParticipationFormationDTO(ParticipationFormation participationFormation, IEnumerable collaborateurDTOs) { if (participationFormation == null || collaborateurDTOs == null || !collaborateurDTOs.Any()) return null; ParticipationFormationDTO participationFormationDTO = new ParticipationFormationDTO() { Id = participationFormation.IdParticipationFormation, DateCreation = participationFormation.DateCreation, Intitule = participationFormation.Formation.Intitule, DateDebut = participationFormation.Formation.DateDebut, Statut = GetStatutFormationDTO(participationFormation.Formation.Statut), Collaborateur = GetCollaborateurDTO(participationFormation, collaborateurDTOs), Ep = GetEpInformationDTO(participationFormation.DemandeFormation.Ep, collaborateurDTOs) }; return participationFormationDTO; } /// /// Récupère un objet CollaborateurDTO en fonction d'un objet ParticipationFormation et d'une liste de CollaborateurDTO /// /// /// private CollaborateurDTO GetCollaborateurDTO(ParticipationFormation participationFormation, IEnumerable collaborateurDTOs) { if (participationFormation == null || collaborateurDTOs == null || !collaborateurDTOs.Any()) return null; return collaborateurDTOs.FirstOrDefault(collaborateurDTO => collaborateurDTO.Id == participationFormation.DemandeFormation.Ep.IdCollaborateur); } /// /// Récupère un objet EpInformationDTO en fonction d'un objet Ep et d'une liste de CollaborateurDTO /// /// /// private EpInformationDTO GetEpInformationDTO(Ep ep, IEnumerable collaborateurDTOs) { CollaborateurDTO collaborateur; CollaborateurDTO referent; if (ep == null || collaborateurDTOs == null || !collaborateurDTOs.Any()) return null; collaborateur = collaborateurDTOs.FirstOrDefault(collaborateurDTO => collaborateurDTO.Id == ep.IdCollaborateur); referent = collaborateurDTOs.FirstOrDefault(collaborateurDTO => collaborateurDTO.Id == ep.IdReferent); EpInformationDTO epInformationDTO = new EpInformationDTO() { Id = ep.IdEP, Type = ep.TypeEP, Statut = ep.Statut, DateDisponibilite = ep.DateDisponibilite, DatePrevisionnelle = ep.DatePrevisionnelle, Obligatoire = ep.Obligatoire, Collaborateur = collaborateur, Referent = referent, }; return epInformationDTO; } #endregion #region DTO to Object /// /// Modifier un objet Formation en fonction d'un objet FormationDTO /// /// /// /// private Formation SetFormation(Formation formation, FormationDTO formationDTO) { if (formation == null || formationDTO == null) return null; formation.Intitule = formationDTO.Intitule; formation.IdAgence = formationDTO.IdAgence.Value; formation.DateDebut = formationDTO.DateDebut.Value; formation.DateFin = formationDTO.DateFin.Value; formation.Heure = Convert.ToInt32(formationDTO.Heure.Value); formation.Jour = Convert.ToInt32(formationDTO.Jour.Value); formation.Organisme = formationDTO.Organisme; formation.EstCertifiee = formationDTO.EstCertifiee.Value; //formation.EstRealisee = formationDTO.EstRealisee.Value; formation.Origine = GetOrigineFormation(formationDTO.Origine); formation.Statut = GetStatutFormation(formationDTO.Statut); formation.ModeFormation = GetModeFormation(formationDTO.Mode); formation.TypeFormation = GetTypeFormation(formationDTO.Type); return formation; } /// /// Récuperer un objet OrigineFormation en fonction d'un objet OrigineFormationDTO /// /// /// private OrigineFormation GetOrigineFormation(OrigineFormationDTO origineFormationDTO) { if (origineFormationDTO == null) return null; OrigineFormation origineFormation = new OrigineFormation() { IdOrigineFormation = origineFormationDTO.Id.Value, Libelle = origineFormationDTO.Libelle }; return origineFormation; } /// /// Récuperer un objet StatutFormation en fonction d'un objet StatutFormationDTO /// /// /// private StatutFormation GetStatutFormation(StatutFormationDTO statutFormationDTO) { if (statutFormationDTO == null) return null; StatutFormation statutFormation = new StatutFormation() { IdStatutFormation = statutFormationDTO.Id.Value, Libelle = statutFormationDTO.Libelle }; return statutFormation; } /// /// Récuperer un objet ModeFormation en fonction d'un objet ModeFormationDTO /// /// /// private ModeFormation GetModeFormation(ModeFormationDTO modeFormationDTO) { if (modeFormationDTO == null) return null; ModeFormation modeFormation = new ModeFormation() { IdModeFormation = modeFormationDTO.Id.Value, Libelle = modeFormationDTO.Libelle }; return modeFormation; } /// /// Récuperer un objet TypeFormation en fonction d'un objet TypeFormationDTO /// /// /// private TypeFormation GetTypeFormation(TypeFormationDTO typeFormationDTO) { if (typeFormationDTO == null) return null; TypeFormation typeFormation = new TypeFormation() { IdTypeFormation = typeFormationDTO.Id.Value, Libelle = typeFormationDTO.Libelle }; return typeFormation; } #endregion #endregion } }