using EPAServeur.Context; using EPAServeur.Exceptions; using EPAServeur.IServices; 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 private readonly EpContext epContext; #endregion #region Contructeurs /// /// Constructeur de la classe FormationService /// /// public FormationService(EpContext _epContext) { epContext = _epContext; } #endregion #region Méthodes Service /// /// Récupérer une formation par son id /// /// /// public FormationDTO GetFormationById(long? idFormation) { Formation formation = epContext.Formation.Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation) .FirstOrDefault(formation => formation.Id == idFormation); if (formation == null) throw new FormationNotFoundException(); return GetFormationDTO(formation); } /// /// 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) .FirstOrDefaultAsync(formation => formation.Id == idFormation); if (formation == null) throw new FormationNotFoundException(); return GetFormationDTO(formation); } /// /// Récupérer la liste des formations /// /// 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 IEnumerable GetFormations(bool? asc, int? numPage, int? parPAge, int? idAgence, int? statutFormation, string texte, string tri) { IEnumerable formations; IEnumerable formationDTOs; if (texte == null) texte = ""; else texte = texte.ToLower(); int skip = (numPage.Value - 1) * parPAge.Value; int take = parPAge.Value; if (statutFormation != null && idAgence != null) { formations = epContext.Formation .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation) .Where(formation => formation.Statut.Id == statutFormation && formation.IdAgence == idAgence); } else if (statutFormation != null && idAgence == null) { formations = epContext.Formation .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation) .Where(formation => formation.Statut.Id == statutFormation); } else if (idAgence != null) { formations = epContext.Formation.Where(formation => formation.IdAgence == idAgence) .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation); } else { formations = epContext.Formation.Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation); } if (formations == null) return null; formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation)); return formationDTOs; } /// /// 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(bool? asc, int? numPage, int? parPAge, int? idAgence, int? statutFormation, string texte, string tri) { IEnumerable formations; IEnumerable formationDTOs; if (texte == null) texte = ""; else texte = texte.ToLower(); int skip = (numPage.Value - 1) * parPAge.Value; int take = parPAge.Value; if (statutFormation != null && idAgence != null) { formations = await epContext.Formation .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation) .Where(formation => formation.Statut.Id == statutFormation && formation.IdAgence == idAgence).ToListAsync(); } else if (statutFormation != null && idAgence == null) { formations = await epContext.Formation .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation) .Where(formation => formation.Statut.Id == statutFormation).ToListAsync(); } else if (idAgence != null) { formations = await epContext.Formation .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation).Where(formation => formation.IdAgence == idAgence).ToListAsync(); } else { formations = await epContext.Formation.Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation).ToListAsync(); } if (formations == null) return null; formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation)); return formationDTOs; } /// /// Récupérer les formations annulées /// /// 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 IEnumerable GetFormationAnnulees(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri) { IEnumerable formations; IEnumerable formationDTOs; if (texte == null) texte = ""; else texte = texte.ToLower(); int skip = (numPage.Value - 1) * parPAge.Value; int take = parPAge.Value; if (idAgence != null) formations = epContext.Formation.Where(formation => formation.IdAgence == idAgence && formation.Statut.Id == 4) .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation); else formations = epContext.Formation.Where(formation => formation.Statut.Id == 4) .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation); if (formations == null) return null; formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation)); return formationDTOs; } /// /// Récupérer les formations annulées 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> GetFormationAnnuleesAsync(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri) { IEnumerable formations; IEnumerable formationDTOs; if (texte == null) texte = ""; else texte = texte.ToLower(); int skip = (numPage.Value - 1) * parPAge.Value; int take = parPAge.Value; if (idAgence != null) formations = await epContext.Formation.Where(formation => formation.IdAgence == idAgence && formation.Statut.Id == 4) .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation).ToListAsync(); else formations = await epContext.Formation.Where(formation => formation.Statut.Id == 4) .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation).ToListAsync(); if (formations == null) return null; formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation)); return formationDTOs; } /// /// Récupérer les formations réalisées /// /// 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 IEnumerable GetFormationRealisee(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri) { IEnumerable formations; IEnumerable formationDTOs; if (texte == null) texte = ""; else texte = texte.ToLower(); int skip = (numPage.Value - 1) * parPAge.Value; int take = parPAge.Value; if (idAgence != null) { formations = epContext.Formation.Where(formation => formation.IdAgence == idAgence && formation.Statut.Id == 3) .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation); } else { formations = epContext.Formation.Where(formation => formation.Statut.Id == 3) .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation); } if (formations == null) return null; formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation)); return formationDTOs; } /// /// Récupérer les formations réalisées 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> GetFormationRealiseeAsync(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri) { IEnumerable formations; IEnumerable formationDTOs; if (texte == null) texte = ""; else texte = texte.ToLower(); int skip = (numPage.Value - 1) * parPAge.Value; int take = parPAge.Value; if (idAgence != null) { formations = await epContext.Formation.Where(formation => formation.IdAgence == idAgence && formation.Statut.Id == 3) .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation).ToListAsync(); } else { formations = await epContext.Formation.Where(formation => formation.Statut.Id == 3) .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation).ToListAsync(); } if (formations == null) return null; formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation)); return formationDTOs; } /// /// Récupérer les formations plannifiées et replannifiées /// /// 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 IEnumerable GetProchainesFormation(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri) { IEnumerable formations; IEnumerable formationDTOs; if (texte == null) texte = ""; else texte = texte.ToLower(); int skip = (numPage.Value - 1) * parPAge.Value; int take = parPAge.Value; if (idAgence != null) { formations = epContext.Formation.Where(formation => formation.IdAgence == idAgence && (formation.Statut.Id == 1 || formation.Statut.Id == 2)) .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation); } else { formations = epContext.Formation.Where(formation => (formation.Statut.Id == 1 || formation.Statut.Id == 2)) .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation); } if (formations == null) return null; formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation)); return formationDTOs; } /// /// Récupérer les formations plannifiées et replannifiées de manè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> GetProchainesFormationAsync(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri) { IEnumerable formations; IEnumerable formationDTOs; if (texte == null) texte = ""; else texte = texte.ToLower(); int skip = (numPage.Value - 1) * parPAge.Value; int take = parPAge.Value; if (idAgence != null) { formations = await epContext.Formation.Where(formation => formation.IdAgence == idAgence && (formation.Statut.Id == 1 || formation.Statut.Id == 2)) .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation).ToListAsync(); } else { formations = await epContext.Formation.Where(formation => (formation.Statut.Id == 1 || formation.Statut.Id == 2)) .Include(formation => formation.Statut) .Include(formation => formation.ModeFormation) .Include(formation => formation.Origine) .Include(formation => formation.TypeFormation).ToListAsync(); } if (formations == null) return null; formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation)); return formationDTOs; } /// /// Récupérer les modes de formation /// /// public IEnumerable GetModesFormation() { IEnumerable modeFormations; IEnumerable modeFormationDTOs; modeFormations = epContext.ModeFormation; if (modeFormations == null) return null; modeFormationDTOs = modeFormations.Select(modeFormation => GetModeFormationDTO(modeFormation)); return modeFormationDTOs; } /// /// Récupérer les modes de formation de manière asynchrone /// /// public async Task> GetModesFormationAsync() { IEnumerable modeFormations; IEnumerable modeFormationDTOs; modeFormations = await epContext.ModeFormation.ToListAsync(); if (modeFormations == null) return null; modeFormationDTOs = modeFormations.Select(modeFormation => GetModeFormationDTO(modeFormation)); return modeFormationDTOs; } /// /// Récupérer les origines de formation /// /// public IEnumerable GetOriginesFormation() { IEnumerable origineFormations; IEnumerable origineFormationDTOs; origineFormations = epContext.OrigineFormation; if (origineFormations == null) return null; origineFormationDTOs = origineFormations.Select(origineFormation => GetOrigineFormationDTO(origineFormation)); return origineFormationDTOs; } /// /// Récupérer les origines de formation de manière asynchrone /// /// public async Task> GetOriginesFormationAsync() { IEnumerable origineFormations; IEnumerable origineFormationDTOs; origineFormations = await epContext.OrigineFormation.ToListAsync(); if (origineFormations == null) return null; origineFormationDTOs = origineFormations.Select(origineFormation => GetOrigineFormationDTO(origineFormation)); return origineFormationDTOs; } /// /// Récupérer les statuts de formation /// /// public IEnumerable GetStatutsFormation() { IEnumerable statutFormations; IEnumerable statutFormationDTOs; statutFormations = epContext.StatutFormation; if (statutFormations == null) return null; statutFormationDTOs = statutFormations.Select(statutFormation => GetStatutFormationDTO(statutFormation)); return statutFormationDTOs; } /// /// Récupérer les statuts de formation de manière asynchrone /// /// public async Task> GetStatutsFormationAsync() { IEnumerable statutFormations; IEnumerable statutFormationDTOs; statutFormations = await epContext.StatutFormation.ToListAsync(); if (statutFormations == null) return null; statutFormationDTOs = statutFormations.Select(statutFormation => GetStatutFormationDTO(statutFormation)); return statutFormationDTOs; } /// /// Récupérer les types de formation /// /// public IEnumerable GetTypesFormation() { IEnumerable typeFormations; IEnumerable typeFormationDTOs; typeFormations = epContext.TypeFormation; if (typeFormations == null) return null; typeFormationDTOs = typeFormations.Select(typeFormation => GetTypeFormationDTO(typeFormation)); return typeFormationDTOs; } /// /// Récupérer les types de formation de manière asynchrone /// /// public async Task> GetTypesFormationAsync() { IEnumerable typeFormations; IEnumerable typeFormationDTOs; typeFormations = await epContext.TypeFormation.ToListAsync(); if (typeFormations == null) return null; typeFormationDTOs = typeFormations.Select(typeFormation => GetTypeFormationDTO(typeFormation)); return typeFormationDTOs; } /// /// Ajouter une formation /// /// /// public FormationDTO AddFormation(FormationDTO formationDTO) { if (!IsFormationValide(formationDTO)) throw new FormationInvalidException(); Formation formation = new Formation(); formation = SetFormation(formation, formationDTO); if (formation.Statut != null) epContext.StatutFormation.Attach(formation.Statut); epContext.OrigineFormation.Attach(formation.Origine); epContext.ModeFormation.Attach(formation.ModeFormation); epContext.TypeFormation.Attach(formation.TypeFormation); epContext.Add(formation); epContext.SaveChanges(); return GetFormationDTO(formation); } /// /// Ajouter une formation de manière asynchrone /// /// /// public async Task AddFormationAsync(FormationDTO formationDTO) { if (!IsFormationValide(formationDTO)) throw new FormationInvalidException(); Formation formation = new Formation(); formation = SetFormation(formation, formationDTO); if (formation.Statut != null) 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 /// /// /// /// public FormationDTO UpdateFormation(long? idFormation, FormationDTO formationDTO) { if (!IsFormationValide(formationDTO)) throw new FormationInvalidException(); if (formationDTO == null && !formationDTO.Id.HasValue && formationDTO.Id.Value != idFormation) throw new FormationIncompatibleIdException(); Formation formation = epContext.Formation.Find(idFormation); if (formation == null) return null; formation = SetFormation(formation, formationDTO); epContext.SaveChanges(); return GetFormationDTO(formation); } /// /// Modifier une formation de manière asynchrone /// /// /// /// public async Task UpdateFormationAsync(long? idFormation, FormationDTO formationDTO) { if (!IsFormationValide(formationDTO)) throw new FormationInvalidException(); if (formationDTO == null && !formationDTO.Id.HasValue && formationDTO.Id.Value != idFormation) throw new FormationIncompatibleIdException(); Formation formation = await epContext.Formation.FindAsync(idFormation); if (formation == null) return null; formation = SetFormation(formation, formationDTO); await epContext.SaveChangesAsync(); return GetFormationDTO(formation); } /// /// Supprimer une formation /// /// /// public FormationDTO DeleteFormationById(long? idFormation) { Formation formation = epContext.Formation.Find(idFormation); if (formation == null) throw new FormationNotFoundException(); epContext.Remove(formation); epContext.SaveChanges(); return GetFormationDTO(formation); } /// /// Supprimer une formation de manière asynchrone /// /// /// public async Task DeleteFormationByIdAsync(long? idFormation) { Formation formation = await epContext.Formation.FindAsync(idFormation); if (formation == null) throw new FormationNotFoundException(); 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 /// /// true si l'objet est valide, false sinon private bool IsFormationValide(FormationDTO formation) { return !(formation == null || formation.IdAgence == null || formation.Intitule == null || formation.Organisme == null); } #region Object to DTO /// /// Récupère un objet FormationDTO en fonction d'un objet Formation /// /// /// private FormationDTO GetFormationDTO(Formation formation) { FormationDTO formationDTO = new FormationDTO() { Id = formation.Id, Intitule = formation.Intitule, IdAgence = formation.IdAgence, DateDebut = formation.DateDebut, DateFin = formation.DateFin, Heure = formation.Heure, Jour = formation.Jour, Organisme = formation.Organisme, EstCertifie = formation.EstCertifiee, Origine = GetOrigineFormationDTO(formation.Origine), Statut = GetStatutFormationDTO(formation.Statut), Mode = GetModeFormationDTO(formation.ModeFormation), Type = GetTypeFormationDTO(formation.TypeFormation) }; return formationDTO; } /// /// Récupère 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.Id, Libelle = origineFormation.Libelle }; return origineFormationDTO; } /// /// Récupère 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.Id, Libelle = statutFormation.Libelle }; return statutFormationDTO; } /// /// Récupère 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.Id, Libelle = modeFormation.Libelle }; return modeFormationDTO; } /// /// Récupère 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.Id, Libelle = typeFormation.Libelle }; return typeFormationDTO; } #endregion #region DTO to Object /// /// Modifie un objet Formation en fonction d'un objet FormationDTO /// /// /// /// private Formation SetFormation(Formation formation, FormationDTO formationDTO) { 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.EstCertifie.Value; formation.Origine = GetOrigineFormation(formationDTO.Origine); formation.Statut = GetStatutFormation(formationDTO.Statut); formation.ModeFormation = GetModeFormation(formationDTO.Mode); formation.TypeFormation = GetTypeFormation(formationDTO.Type); return formation; } /// /// Récupère un objet OrigineFormation en fonction d'un objet OrigineFormationDTO /// /// /// private OrigineFormation GetOrigineFormation(OrigineFormationDTO origineFormationDTO) { if (origineFormationDTO == null) return null; OrigineFormation origineFormation = new OrigineFormation() { Id = origineFormationDTO.Id.Value, Libelle = origineFormationDTO.Libelle }; return origineFormation; } /// /// Récupère un objet StatutFormation en fonction d'un objet StatutFormationDTO /// /// /// private StatutFormation GetStatutFormation(StatutFormationDTO statutFormationDTO) { if (statutFormationDTO == null) return null; StatutFormation statutFormation = new StatutFormation() { Id = statutFormationDTO.Id.Value, Libelle = statutFormationDTO.Libelle }; return statutFormation; } /// /// Récupère un objet ModeFormation en fonction d'un objet ModeFormationDTO /// /// /// private ModeFormation GetModeFormation(ModeFormationDTO modeFormationDTO) { if (modeFormationDTO == null) return null; ModeFormation modeFormation = new ModeFormation() { Id = modeFormationDTO.Id.Value, Libelle = modeFormationDTO.Libelle }; return modeFormation; } /// /// Récupère un objet TypeFormation en fonction d'un objet TypeFormationDTO /// /// /// private TypeFormation GetTypeFormation(TypeFormationDTO typeFormationDTO) { if (typeFormationDTO == null) return null; TypeFormation typeFormation = new TypeFormation() { Id = typeFormationDTO.Id.Value, Libelle = typeFormationDTO.Libelle }; return typeFormation; } #endregion #endregion } }