|
|
|
@ -73,6 +73,9 @@ namespace EPAServeur.Services |
|
|
|
|
.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) |
|
|
|
@ -91,17 +94,18 @@ namespace EPAServeur.Services |
|
|
|
|
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
|
|
|
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
public async Task<IEnumerable<FormationDTO>> GetFormationsAsync(long? idAgence, List<int?> idStatuts, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
|
public async Task<IEnumerable<FormationDetailsDTO>> GetFormationsAsync(long? idAgence, List<int?> idStatuts, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
|
{ |
|
|
|
|
IQueryable<Formation> query; |
|
|
|
|
IEnumerable<Formation> formations; |
|
|
|
|
IEnumerable<FormationDTO> formationDTOs; |
|
|
|
|
IEnumerable<FormationDetailsDTO> formationDTOs; |
|
|
|
|
|
|
|
|
|
query = epContext.Formation |
|
|
|
|
.Include(formation => formation.Statut) |
|
|
|
|
.Include(formation => formation.ModeFormation) |
|
|
|
|
.Include(formation => formation.Origine) |
|
|
|
|
.Include(formation => formation.TypeFormation); |
|
|
|
|
.Include(formation => formation.TypeFormation) |
|
|
|
|
.Include(formation => formation.ParticipationsFormation); |
|
|
|
|
|
|
|
|
|
query = IdStatutsFilter(query, idStatuts); |
|
|
|
|
|
|
|
|
@ -117,7 +121,7 @@ namespace EPAServeur.Services |
|
|
|
|
|
|
|
|
|
formations = await query.ToListAsync(); |
|
|
|
|
|
|
|
|
|
formationDTOs = formations.Select(formation => GetFormationDTO(formation)); |
|
|
|
|
formationDTOs = formations.Select(formation => GetFormationDetailsDTO(formation)); |
|
|
|
|
|
|
|
|
|
return formationDTOs; |
|
|
|
|
} |
|
|
|
@ -140,7 +144,8 @@ namespace EPAServeur.Services |
|
|
|
|
.Include(formation => formation.Statut) |
|
|
|
|
.Include(formation => formation.ModeFormation) |
|
|
|
|
.Include(formation => formation.Origine) |
|
|
|
|
.Include(formation => formation.TypeFormation); |
|
|
|
|
.Include(formation => formation.TypeFormation) |
|
|
|
|
.Include(formation => formation.ParticipationsFormation); |
|
|
|
|
|
|
|
|
|
query = IntituleFilter(query, texte); |
|
|
|
|
|
|
|
|
@ -517,7 +522,31 @@ namespace EPAServeur.Services |
|
|
|
|
Origine = GetOrigineFormationDTO(formation.Origine), |
|
|
|
|
Statut = GetStatutFormationDTO(formation.Statut), |
|
|
|
|
Mode = GetModeFormationDTO(formation.ModeFormation), |
|
|
|
|
Type = GetTypeFormationDTO(formation.TypeFormation) |
|
|
|
|
Type = GetTypeFormationDTO(formation.TypeFormation), |
|
|
|
|
Participations = GetParticipationsFormationDTO(formation.ParticipationsFormation) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return formationDTO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Récuperer un objet FormationDetailsDTO en fonction d'un objet Formation |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="formation"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
private FormationDetailsDTO GetFormationDetailsDTO(Formation formation) |
|
|
|
|
{ |
|
|
|
|
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; |
|
|
|
@ -573,6 +602,7 @@ namespace EPAServeur.Services |
|
|
|
|
}; |
|
|
|
|
return modeFormationDTO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Récuperer un objet TypeFormationDTO en fonction d'un objet TypeFormation |
|
|
|
|
/// </summary> |
|
|
|
@ -590,6 +620,43 @@ namespace EPAServeur.Services |
|
|
|
|
return typeFormationDTO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Récuperer une liste de ParticipationFormationDTO en fonction d'une liste de ParticipationFormation |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="typeFormation"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
private List<ParticipationFormationDTO> GetParticipationsFormationDTO(List<ParticipationFormation> participationsFormation) |
|
|
|
|
{ |
|
|
|
|
List<ParticipationFormationDTO> participationFormationDTOs; |
|
|
|
|
|
|
|
|
|
if (participationsFormation == null || participationsFormation.Count == 0) |
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
participationFormationDTOs = participationsFormation.Select(participationFormation => GetParticipationFormationDTO(participationFormation)).ToList(); |
|
|
|
|
|
|
|
|
|
return participationFormationDTOs; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Récuperer un objet ParticipationFormationDTO en fonction d'un objet ParticipationFormation |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="participationFormation"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
private ParticipationFormationDTO GetParticipationFormationDTO(ParticipationFormation participationFormation) |
|
|
|
|
{ |
|
|
|
|
if (participationFormation == null) |
|
|
|
|
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), |
|
|
|
|
}; |
|
|
|
|
return participationFormationDTO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region DTO to Object |
|
|
|
|