|
|
|
@ -10,6 +10,7 @@ using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Diagnostics; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
|
namespace EPAServeur.Services |
|
|
|
|
{ |
|
|
|
@ -98,7 +99,7 @@ namespace EPAServeur.Services |
|
|
|
|
{ |
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
@ -109,7 +110,7 @@ namespace EPAServeur.Services |
|
|
|
|
{ |
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
@ -125,10 +126,10 @@ namespace EPAServeur.Services |
|
|
|
|
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<EngagementDTO> engagementDTOs; |
|
|
|
|
//<EngagementDTO> engagementDTOs = new List<EngagementDTO>(); |
|
|
|
|
|
|
|
|
|
if (texte == null) |
|
|
|
|
texte = ""; |
|
|
|
@ -142,7 +143,7 @@ namespace EPAServeur.Services |
|
|
|
|
{ |
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
@ -153,7 +154,7 @@ namespace EPAServeur.Services |
|
|
|
|
{ |
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
@ -165,8 +166,14 @@ namespace EPAServeur.Services |
|
|
|
|
if (engagements == null) |
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
engagementDTOs = engagements.Where(engagement => engagement.Modalite.ToLower().Contains(texte)).Select(engagement => GetEngagementDTO(engagement)); |
|
|
|
|
return engagementDTOs; |
|
|
|
|
var engagementDTOs = engagements.Where(engagement => engagement.Modalite.ToLower().Contains(texte)).Select(engagement => GetEngagementDTOAsync(engagement)); |
|
|
|
|
var results = await Task.WhenAll(engagementDTOs); |
|
|
|
|
//foreach (var engagement in engagements) |
|
|
|
|
//{ |
|
|
|
|
// engagementDTOs.Add(await GetEngagementDTOAsync(engagement)); |
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
return results; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -175,7 +182,7 @@ namespace EPAServeur.Services |
|
|
|
|
/// <param name="engagementDTO"></param> |
|
|
|
|
/// <param name="idEngagement"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
public EngagementDTO RepondreEngagement(EngagementDTO engagementDTO, long? idEngagement) |
|
|
|
|
public async Task<EngagementDTO> RepondreEngagement(EngagementDTO engagementDTO, long? idEngagement) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if (!IsEngagementValide(engagementDTO)) |
|
|
|
@ -202,7 +209,7 @@ namespace EPAServeur.Services |
|
|
|
|
|
|
|
|
|
epContext.SaveChanges(); |
|
|
|
|
|
|
|
|
|
return GetEngagementDTO(engagement); |
|
|
|
|
return await GetEngagementDTOAsync(engagement); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -215,6 +222,7 @@ namespace EPAServeur.Services |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#region Object to DTO |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Récupère un objet EngagementDTO en fonction d'un objet Engagement |
|
|
|
|
/// </summary> |
|
|
|
@ -238,12 +246,35 @@ namespace EPAServeur.Services |
|
|
|
|
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> |
|
|
|
|
/// Récupère un objet EpInformationDTO en fonction d'un objet Ep |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="ep"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
private EpInformationDTO GetEpInformationDTO(Ep ep) |
|
|
|
|
private EpInformationDTO GetEpInformationDTO(Ep ep) |
|
|
|
|
{ |
|
|
|
|
EpInformationDTO epInformationDTO = new EpInformationDTO() |
|
|
|
|
{ |
|
|
|
@ -252,13 +283,36 @@ namespace EPAServeur.Services |
|
|
|
|
Statut = ep.Statut.ToString(), |
|
|
|
|
DatePrevisionnelle = ep.DatePrevisionnelle, |
|
|
|
|
Obligatoire = ep.Obligatoire, |
|
|
|
|
Collaborateur = collaborateurService.GetProfilById(ep.IdCollaborateur) |
|
|
|
|
//Referent = null //collaborateurService.GetProfilById(ep.IdReferent) |
|
|
|
|
Collaborateur = collaborateurService.GetCollaborateurById(ep.IdCollaborateur), |
|
|
|
|
Referent = collaborateurService.GetCollaborateurById(ep.IdReferent) |
|
|
|
|
//Ajouter la date de disponibilité |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
|
#region DTO to Object |
|
|
|
|