|
|
|
@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore.ChangeTracking; |
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Runtime.InteropServices.ComTypes; |
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
|
namespace EPAServeur.Services |
|
|
|
@ -20,64 +21,81 @@ namespace EPAServeur.Services |
|
|
|
|
collaborateurApi = _collaborateurApi; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public CollaborateurDTO GetCollaborateurById(Guid? id) |
|
|
|
|
// |
|
|
|
|
public AgenceDTO GetAgenceDTO(Agence agence) |
|
|
|
|
{ |
|
|
|
|
Collaborateur collaborateur = collaborateurApi.ChercherCollabId(id); |
|
|
|
|
if (collaborateur == null) |
|
|
|
|
if (agence == null) |
|
|
|
|
return null; |
|
|
|
|
CollaborateurDTO collaborateurDTO = new CollaborateurDTO() |
|
|
|
|
AgenceDTO agenceDTO = new AgenceDTO() |
|
|
|
|
{ |
|
|
|
|
Id = collaborateur.Id, |
|
|
|
|
Prenom = collaborateur.Prenom, |
|
|
|
|
Nom = collaborateur.Nom, |
|
|
|
|
MailApside = collaborateur.MailApside, |
|
|
|
|
DateArrivee = collaborateur.DateArrivee, |
|
|
|
|
|
|
|
|
|
Id = agence.Id, |
|
|
|
|
Nom = agence.Nom, |
|
|
|
|
Bu = new List<BusinessUnitDTO>() |
|
|
|
|
}; |
|
|
|
|
collaborateurDTO.BusinessUnit = new BusinessUnitDTO() |
|
|
|
|
foreach(BU bu in agence.Bus) |
|
|
|
|
{ |
|
|
|
|
Id = collaborateur.BusinessUnit.Id, |
|
|
|
|
Nom = collaborateur.BusinessUnit.Nom, |
|
|
|
|
Agence = new AgenceDTO() |
|
|
|
|
agenceDTO.Bu.Add(new BusinessUnitDTO() |
|
|
|
|
{ |
|
|
|
|
Id = collaborateur.BusinessUnit.Agence.Id, |
|
|
|
|
Nom = collaborateur.BusinessUnit.Agence.Nom |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
collaborateurDTO.Referent = new ReferentDTO() |
|
|
|
|
Id = bu.Id, |
|
|
|
|
Nom = bu.Nom |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
return agenceDTO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public BusinessUnitDTO GetBusinessUnitDTO(BU businessUnit) |
|
|
|
|
{ |
|
|
|
|
if (businessUnit == null) |
|
|
|
|
return null; |
|
|
|
|
BusinessUnitDTO businessUnitDTO = new BusinessUnitDTO() |
|
|
|
|
{ |
|
|
|
|
Id = collaborateur.Referent.Id, |
|
|
|
|
Prenom = collaborateur.Referent.Prenom, |
|
|
|
|
Nom = collaborateur.Referent.Nom, |
|
|
|
|
MailApside = collaborateur.Referent.MailApside |
|
|
|
|
Id = businessUnit.Id, |
|
|
|
|
Nom = businessUnit.Nom, |
|
|
|
|
Agence = GetAgenceDTO(businessUnit.Agence) |
|
|
|
|
}; |
|
|
|
|
return collaborateurDTO; |
|
|
|
|
return businessUnitDTO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public CollaborateurDTO GetCollaborateurById(Guid? id) |
|
|
|
|
{ |
|
|
|
|
Collaborateur collaborateur = collaborateurApi.ChercherCollabId(id); |
|
|
|
|
if (collaborateur == null) |
|
|
|
|
return null; |
|
|
|
|
return GetCollaborateurDTO(collaborateur); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public CollaborateurDTO GetCollaborateurByMail(string mail) |
|
|
|
|
{ |
|
|
|
|
Collaborateur collaborateur = collaborateurApi.ChercherCollabMail(mail); |
|
|
|
|
if (collaborateur == null) |
|
|
|
|
return null; |
|
|
|
|
return GetCollaborateurDTO(collaborateur); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public CollaborateurDTO GetCollaborateurDTO(Collaborateur collaborateur) |
|
|
|
|
{ |
|
|
|
|
CollaborateurDTO collaborateurDTO = new CollaborateurDTO() |
|
|
|
|
{ |
|
|
|
|
Id = collaborateur.Id, |
|
|
|
|
Prenom = collaborateur.Prenom, |
|
|
|
|
Nom = collaborateur.Nom, |
|
|
|
|
MailApside = collaborateur.MailApside, |
|
|
|
|
DateArrivee = collaborateur.DateArrivee |
|
|
|
|
}; |
|
|
|
|
collaborateurDTO.Referent = new ReferentDTO() |
|
|
|
|
{ |
|
|
|
|
Id = collaborateur.Referent.Id, |
|
|
|
|
Prenom = collaborateur.Referent.Prenom, |
|
|
|
|
Nom = collaborateur.Referent.Nom, |
|
|
|
|
MailApside = collaborateur.Referent.MailApside |
|
|
|
|
DateArrivee = collaborateur.DateArrivee, |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
collaborateurDTO.BusinessUnit = GetBusinessUnitDTO(collaborateur.BusinessUnit); |
|
|
|
|
collaborateurDTO.Referent = GetReferentDTO(collaborateur.Referent); |
|
|
|
|
return collaborateurDTO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<CollaborateurDTO> GetCollaborateurs() |
|
|
|
|
{ |
|
|
|
|
throw new NotImplementedException(); |
|
|
|
|
List<Collaborateur> collaborateurs = collaborateurApi.ChercherCollab(); |
|
|
|
|
List<CollaborateurDTO> collaborateursDTO = (from c in collaborateurs |
|
|
|
|
select GetCollaborateurDTO(c)).ToList(); |
|
|
|
|
//List<CollaborateurDTO> collaborateursDTO = collaborateurs.Select(c => GetCollaborateurDTO(c)).ToList(); |
|
|
|
|
|
|
|
|
|
return collaborateursDTO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<CollaborateurDTO> GetCollaborateursByReferent(Guid? idReferent) |
|
|
|
@ -108,5 +126,19 @@ namespace EPAServeur.Services |
|
|
|
|
{ |
|
|
|
|
throw new NotImplementedException(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ReferentDTO GetReferentDTO(Collaborateur referent) |
|
|
|
|
{ |
|
|
|
|
if (referent == null) |
|
|
|
|
return null; |
|
|
|
|
ReferentDTO referentDTO = new ReferentDTO() |
|
|
|
|
{ |
|
|
|
|
Id = referent.Id, |
|
|
|
|
Prenom = referent.Prenom, |
|
|
|
|
Nom = referent.Nom, |
|
|
|
|
MailApside = referent.MailApside |
|
|
|
|
}; |
|
|
|
|
return referentDTO; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|