|
|
@ -10,6 +10,7 @@ using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq; |
|
|
|
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
|
|
|
namespace EPAServeur.Services |
|
|
|
namespace EPAServeur.Services |
|
|
|
{ |
|
|
|
{ |
|
|
@ -98,7 +99,7 @@ namespace EPAServeur.Services |
|
|
|
{ |
|
|
|
{ |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
engagements = epContext.Engagement.Include(engagement => engagement.Ep).Where(engagement => engagement.Ep.IdAgence == idAgence && engagement.Realise == null); |
|
|
|
engagements = epContext.Engagement.Include(engagement => engagement.Ep).Where(engagement => engagement.Ep.IdAgence == idAgence && engagement.Realise == null).ToList(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -109,7 +110,7 @@ namespace EPAServeur.Services |
|
|
|
{ |
|
|
|
{ |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
engagements = epContext.Engagement.Include(engagement => engagement.Ep).Where(engagement => engagement.Realise == null); |
|
|
|
engagements = epContext.Engagement.Include(engagement => engagement.Ep).Where(engagement => engagement.Realise == null).ToList(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -125,10 +126,10 @@ namespace EPAServeur.Services |
|
|
|
return engagementDTOs; |
|
|
|
return engagementDTOs; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<EngagementDTO> GetEngagementsRepondus(bool? asc, int? numPage, int? parPAge, long? idAgence, string texte, string tri) |
|
|
|
public async Task<IList<EngagementDTO>> GetEngagementsRepondus(bool? asc, int? numPage, int? parPAge, long? idAgence, string texte, string tri) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IEnumerable<Engagement> engagements; |
|
|
|
IEnumerable<Engagement> engagements; |
|
|
|
IEnumerable<EngagementDTO> engagementDTOs; |
|
|
|
//<EngagementDTO> engagementDTOs = new List<EngagementDTO>(); |
|
|
|
|
|
|
|
|
|
|
|
if (texte == null) |
|
|
|
if (texte == null) |
|
|
|
texte = ""; |
|
|
|
texte = ""; |
|
|
@ -142,7 +143,7 @@ namespace EPAServeur.Services |
|
|
|
{ |
|
|
|
{ |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
engagements = epContext.Engagement.Include(engagement => engagement.Ep).Where(engagement => engagement.Ep.IdAgence == idAgence && engagement.Realise != null); |
|
|
|
engagements = epContext.Engagement.Include(engagement => engagement.Ep).Where(engagement => engagement.Ep.IdAgence == idAgence && engagement.Modalite.ToLower().Contains(texte)); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -153,7 +154,7 @@ namespace EPAServeur.Services |
|
|
|
{ |
|
|
|
{ |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
engagements = epContext.Engagement.Include(engagement => engagement.Ep).Where(engagement => engagement.Realise != null); |
|
|
|
engagements = epContext.Engagement.Include(engagement => engagement.Ep).Where(engagement => engagement.Realise != null && engagement.Modalite.ToLower().Contains(texte)); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -165,8 +166,14 @@ namespace EPAServeur.Services |
|
|
|
if (engagements == null) |
|
|
|
if (engagements == null) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
engagementDTOs = engagements.Where(engagement => engagement.Modalite.ToLower().Contains(texte)).Select(engagement => GetEngagementDTO(engagement)); |
|
|
|
var engagementDTOs = engagements.Where(engagement => engagement.Modalite.ToLower().Contains(texte)).Select(engagement => GetEngagementDTOAsync(engagement)); |
|
|
|
return engagementDTOs; |
|
|
|
var results = await Task.WhenAll(engagementDTOs); |
|
|
|
|
|
|
|
//foreach (var engagement in engagements) |
|
|
|
|
|
|
|
//{ |
|
|
|
|
|
|
|
// engagementDTOs.Add(await GetEngagementDTOAsync(engagement)); |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return results; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
@ -175,7 +182,7 @@ namespace EPAServeur.Services |
|
|
|
/// <param name="engagementDTO"></param> |
|
|
|
/// <param name="engagementDTO"></param> |
|
|
|
/// <param name="idEngagement"></param> |
|
|
|
/// <param name="idEngagement"></param> |
|
|
|
/// <returns></returns> |
|
|
|
/// <returns></returns> |
|
|
|
public EngagementDTO RepondreEngagement(EngagementDTO engagementDTO, long? idEngagement) |
|
|
|
public async Task<EngagementDTO> RepondreEngagement(EngagementDTO engagementDTO, long? idEngagement) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if (!IsEngagementValide(engagementDTO)) |
|
|
|
if (!IsEngagementValide(engagementDTO)) |
|
|
@ -202,7 +209,7 @@ namespace EPAServeur.Services |
|
|
|
|
|
|
|
|
|
|
|
epContext.SaveChanges(); |
|
|
|
epContext.SaveChanges(); |
|
|
|
|
|
|
|
|
|
|
|
return GetEngagementDTO(engagement); |
|
|
|
return await GetEngagementDTOAsync(engagement); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -215,6 +222,7 @@ namespace EPAServeur.Services |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region Object to DTO |
|
|
|
#region Object to DTO |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// Récupère un objet EngagementDTO en fonction d'un objet Engagement |
|
|
|
/// Récupère un objet EngagementDTO en fonction d'un objet Engagement |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
@ -238,6 +246,29 @@ namespace EPAServeur.Services |
|
|
|
return engagementDTO; |
|
|
|
return engagementDTO; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// Récupère un objet EngagementDTO en fonction d'un objet Engagement |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <param name="engagement"></param> |
|
|
|
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
|
|
private async Task<EngagementDTO> GetEngagementDTOAsync(Engagement engagement) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
EngagementDTO engagementDTO = new EngagementDTO() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Id = engagement.Id, |
|
|
|
|
|
|
|
Action = engagement.Action, |
|
|
|
|
|
|
|
DatePrevisionnelle = engagement.DateLimite, |
|
|
|
|
|
|
|
Dispositif = engagement.Disposition, |
|
|
|
|
|
|
|
Modalite = engagement.Modalite, |
|
|
|
|
|
|
|
RaisonNonRealisable = engagement.RaisonNonRealisable, |
|
|
|
|
|
|
|
Realisable = engagement.Realisable, |
|
|
|
|
|
|
|
Realise = engagement.Realise, |
|
|
|
|
|
|
|
Ep = await GetEpInformationDTOAsync(engagement.Ep) |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return engagementDTO; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// Récupère un objet EpInformationDTO en fonction d'un objet Ep |
|
|
|
/// Récupère un objet EpInformationDTO en fonction d'un objet Ep |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
@ -252,13 +283,36 @@ namespace EPAServeur.Services |
|
|
|
Statut = ep.Statut.ToString(), |
|
|
|
Statut = ep.Statut.ToString(), |
|
|
|
DatePrevisionnelle = ep.DatePrevisionnelle, |
|
|
|
DatePrevisionnelle = ep.DatePrevisionnelle, |
|
|
|
Obligatoire = ep.Obligatoire, |
|
|
|
Obligatoire = ep.Obligatoire, |
|
|
|
Collaborateur = collaborateurService.GetProfilById(ep.IdCollaborateur) |
|
|
|
Collaborateur = collaborateurService.GetCollaborateurById(ep.IdCollaborateur), |
|
|
|
//Referent = null //collaborateurService.GetProfilById(ep.IdReferent) |
|
|
|
Referent = collaborateurService.GetCollaborateurById(ep.IdReferent) |
|
|
|
//Ajouter la date de disponibilité |
|
|
|
//Ajouter la date de disponibilité |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return epInformationDTO; |
|
|
|
return epInformationDTO; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// Récupère un objet EpInformationDTO en fonction d'un objet Ep |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <param name="ep"></param> |
|
|
|
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
|
|
private async Task<EpInformationDTO> GetEpInformationDTOAsync(Ep ep) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
EpInformationDTO epInformationDTO = new EpInformationDTO() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Id = ep.Id, |
|
|
|
|
|
|
|
Type = ep.TypeEP.ToString(), |
|
|
|
|
|
|
|
Statut = ep.Statut.ToString(), |
|
|
|
|
|
|
|
DatePrevisionnelle = ep.DatePrevisionnelle, |
|
|
|
|
|
|
|
Obligatoire = ep.Obligatoire, |
|
|
|
|
|
|
|
Collaborateur = await collaborateurService.GetCollaborateurByIdAsync(ep.IdCollaborateur), |
|
|
|
|
|
|
|
Referent = await collaborateurService.GetCollaborateurByIdAsync(ep.IdReferent) |
|
|
|
|
|
|
|
//Ajouter la date de disponibilité |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return epInformationDTO; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
#region DTO to Object |
|
|
|
#region DTO to Object |
|
|
|