|
|
|
@ -5,6 +5,7 @@ using IO.Swagger.ModelCollaborateur; |
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
|
namespace EPAServeur.Services |
|
|
|
|
{ |
|
|
|
@ -12,13 +13,14 @@ namespace EPAServeur.Services |
|
|
|
|
{ |
|
|
|
|
#region Variables |
|
|
|
|
private readonly IReferentApi referentApi; |
|
|
|
|
|
|
|
|
|
private readonly ICollaborateurApi collaborateurApi; |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region Contructeurs |
|
|
|
|
public ReferentService(IReferentApi _referentApi) |
|
|
|
|
public ReferentService(IReferentApi _referentApi, ICollaborateurApi _collaborateurApi) |
|
|
|
|
{ |
|
|
|
|
referentApi = _referentApi; |
|
|
|
|
collaborateurApi = _collaborateurApi; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
@ -39,6 +41,20 @@ namespace EPAServeur.Services |
|
|
|
|
return GetReferentDTO(referent); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Récupère un référent par son id de manière asynchrone |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="idReferent"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
public async Task<ReferentDTO> GetReferentByIdAsync(Guid? idReferent) |
|
|
|
|
{ |
|
|
|
|
Referent referent = await referentApi.ChercherRefIdAsync(idReferent); |
|
|
|
|
if (referent == null) |
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
return GetReferentDTO(referent); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Récupère un référent en fonction d'un collaborateur |
|
|
|
|
/// </summary> |
|
|
|
@ -54,6 +70,20 @@ namespace EPAServeur.Services |
|
|
|
|
return GetReferentDTO(referent); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Récupère un référent en fonction d'un collaborateur de manière asynchrone |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="idCollaborateur"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
public async Task<ReferentDTO> GetReferentActuelCollaborateurAsync(Guid? idCollaborateur) |
|
|
|
|
{ |
|
|
|
|
Referent referent = await referentApi.ChercherRefActuelCollabIdAsync(idCollaborateur); |
|
|
|
|
|
|
|
|
|
if (referent == null) |
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
return GetReferentDTO(referent); |
|
|
|
|
} |
|
|
|
|
/// <summary> |
|
|
|
|
/// Récupère la liste des référents pour une agence |
|
|
|
|
/// </summary> |
|
|
|
@ -66,7 +96,78 @@ namespace EPAServeur.Services |
|
|
|
|
/// <param name="texte"></param> |
|
|
|
|
/// <param name="tri"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
|
|
|
|
public IEnumerable<ReferentDTO> GetReferents(bool? asc, int? numPage, int? parPAge, List<string> fonctions, long? idAgence, long? idBU, string texte, string tri) |
|
|
|
|
{ |
|
|
|
|
//IEnumerable<Collaborateur> collaborateurs; // A changer (Sera utilisé pour récupérer la liste des référents par fonction |
|
|
|
|
IEnumerable<Referent> referents = null; // A changer |
|
|
|
|
IEnumerable<ReferentDTO> referentDTOs = null; // A changer |
|
|
|
|
//List<Guid?> ids = fonctions.Select(guid => (Guid?)Guid.Parse(guid)).ToList(); |
|
|
|
|
|
|
|
|
|
//collaborateurs = collaborateurApi.ChercherCollab(ids); |
|
|
|
|
if (texte == null) |
|
|
|
|
texte = ""; |
|
|
|
|
else |
|
|
|
|
texte = texte.ToLower(); |
|
|
|
|
|
|
|
|
|
int skip = (numPage.Value - 1) * parPAge.Value; |
|
|
|
|
int take = parPAge.Value; |
|
|
|
|
|
|
|
|
|
if (idBU != null) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (idAgence != null) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (referents == null) |
|
|
|
|
return new List<ReferentDTO>(); |
|
|
|
|
|
|
|
|
|
referentDTOs = referents.Where(referent => (referent.Nom + " " + referent.Prenom).ToLower().Contains(texte) || (referent.Prenom + " " + referent.Nom).ToLower().Contains(texte)).Select(referent => GetReferentDTO(referent)); |
|
|
|
|
|
|
|
|
|
return referentDTOs; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Récupère la liste des référents pour une agence de manière asynchrone |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="asc"></param> |
|
|
|
|
/// <param name="numPage"></param> |
|
|
|
|
/// <param name="parPAge"></param> |
|
|
|
|
/// <param name="fonctions"></param> |
|
|
|
|
/// <param name="idAgence"></param> |
|
|
|
|
/// <param name="idBU"></param> |
|
|
|
|
/// <param name="texte"></param> |
|
|
|
|
/// <param name="tri"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<ReferentDTO>> GetReferentsAsync(bool? asc, int? numPage, int? parPAge, List<string> fonctions, long? idAgence, long? idBU, string texte, string tri) |
|
|
|
|
{ |
|
|
|
|
IEnumerable<Referent> referents = null ; // A changer |
|
|
|
|
IEnumerable<ReferentDTO> referentDTOs = null; // A changer |
|
|
|
@ -120,6 +221,7 @@ namespace EPAServeur.Services |
|
|
|
|
return referentDTOs; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Récupère la liste des référents pour un collaborateur |
|
|
|
|
/// </summary> |
|
|
|
@ -152,6 +254,40 @@ namespace EPAServeur.Services |
|
|
|
|
|
|
|
|
|
return referentDTOs; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Récupère la liste des référents pour un collaborateur de manère asynchrone |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="asc"></param> |
|
|
|
|
/// <param name="idCollaborateur"></param> |
|
|
|
|
/// <param name="numPage"></param> |
|
|
|
|
/// <param name="parPAge"></param> |
|
|
|
|
/// <param name="texte"></param> |
|
|
|
|
/// <param name="tri"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
public async Task<IEnumerable<ReferentDTO>> GetReferentsByCollaborateurAsync(bool? asc, Guid? idCollaborateur, int? numPage, int? parPAge, string texte, string tri) |
|
|
|
|
{ |
|
|
|
|
IEnumerable<Referent> referents; |
|
|
|
|
IEnumerable<ReferentDTO> referentDTOs; |
|
|
|
|
|
|
|
|
|
if (texte == null) |
|
|
|
|
texte = ""; |
|
|
|
|
else |
|
|
|
|
texte = texte.ToLower(); |
|
|
|
|
|
|
|
|
|
int skip = (numPage.Value - 1) * parPAge.Value; |
|
|
|
|
int take = parPAge.Value; |
|
|
|
|
|
|
|
|
|
if (idCollaborateur == null) |
|
|
|
|
return new List<ReferentDTO>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
referents = await referentApi.ChercherRefCollabIdAsync(idCollaborateur); |
|
|
|
|
referentDTOs = referents.Where(referent => (referent.Nom + " " + referent.Prenom).ToLower().Contains(texte) || (referent.Prenom + " " + referent.Nom).ToLower().Contains(texte)).Select(referent => GetReferentDTO(referent)); |
|
|
|
|
|
|
|
|
|
return referentDTOs; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region Méthodes Privées |
|
|
|
@ -238,6 +374,25 @@ namespace EPAServeur.Services |
|
|
|
|
}; |
|
|
|
|
return referentDTO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Récupère un objet ReferentDTO en fonction d'un objet Collaborateur |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="referent"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
private ReferentDTO GetReferentDTO(Collaborateur collaborateur) |
|
|
|
|
{ |
|
|
|
|
if (collaborateur == null) |
|
|
|
|
return null; |
|
|
|
|
ReferentDTO referentDTO = new ReferentDTO() |
|
|
|
|
{ |
|
|
|
|
Id = collaborateur.Id, |
|
|
|
|
Prenom = collaborateur.Prenom, |
|
|
|
|
Nom = collaborateur.Nom, |
|
|
|
|
MailApside = collaborateur.MailApside |
|
|
|
|
}; |
|
|
|
|
return referentDTO; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region DTO to Object |
|
|
|
|