You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
144 lines
3.8 KiB
144 lines
3.8 KiB
using EPAServeur.Context;
|
|
using EPAServeur.IServices;
|
|
using IO.Swagger.ApiCollaborateur;
|
|
using IO.Swagger.DTO;
|
|
using IO.Swagger.ModelCollaborateur;
|
|
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
|
|
{
|
|
public class CollaborateurService : ICollaborateurService
|
|
{
|
|
private readonly ICollaborateurApi collaborateurApi;
|
|
|
|
public CollaborateurService(ICollaborateurApi _collaborateurApi)
|
|
{
|
|
collaborateurApi = _collaborateurApi;
|
|
}
|
|
|
|
//
|
|
public AgenceDTO GetAgenceDTO(Agence agence)
|
|
{
|
|
if (agence == null)
|
|
return null;
|
|
AgenceDTO agenceDTO = new AgenceDTO()
|
|
{
|
|
Id = agence.Id,
|
|
Nom = agence.Nom,
|
|
Bu = new List<BusinessUnitDTO>()
|
|
};
|
|
foreach(BU bu in agence.Bus)
|
|
{
|
|
agenceDTO.Bu.Add(new BusinessUnitDTO()
|
|
{
|
|
Id = bu.Id,
|
|
Nom = bu.Nom
|
|
});
|
|
}
|
|
return agenceDTO;
|
|
}
|
|
|
|
public BusinessUnitDTO GetBusinessUnitDTO(BU businessUnit)
|
|
{
|
|
if (businessUnit == null)
|
|
return null;
|
|
BusinessUnitDTO businessUnitDTO = new BusinessUnitDTO()
|
|
{
|
|
Id = businessUnit.Id,
|
|
Nom = businessUnit.Nom,
|
|
Agence = GetAgenceDTO(businessUnit.Agence)
|
|
};
|
|
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.BusinessUnit = GetBusinessUnitDTO(collaborateur.BusinessUnit);
|
|
collaborateurDTO.Referent = GetReferentDTO(collaborateur.Referent);
|
|
return collaborateurDTO;
|
|
}
|
|
|
|
public List<CollaborateurDTO> GetCollaborateurs()
|
|
{
|
|
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)
|
|
{
|
|
/*
|
|
Collaborateur collaborateur = collaborateurApi.ChercherCollabRef(idReferent);
|
|
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
|
|
};
|
|
return collaborateurDTO;
|
|
*/
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public ProfilDTO GetProfilByMail(string mail)
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|