diff --git a/EPAServeur/Controllers/DemandesEPIApi.cs b/EPAServeur/Controllers/DemandesEPIApi.cs index 57f6786..bf9a458 100644 --- a/EPAServeur/Controllers/DemandesEPIApi.cs +++ b/EPAServeur/Controllers/DemandesEPIApi.cs @@ -18,6 +18,7 @@ using IO.Swagger.Attributes; using IO.Swagger.Security; using Microsoft.AspNetCore.Authorization; using IO.Swagger.DTO; +using IO.Swagger.Enum; namespace IO.Swagger.Controllers { diff --git a/EPAServeur/Controllers/DemandesFormationApi.cs b/EPAServeur/Controllers/DemandesFormationApi.cs index 8c9cd22..7e4fe39 100644 --- a/EPAServeur/Controllers/DemandesFormationApi.cs +++ b/EPAServeur/Controllers/DemandesFormationApi.cs @@ -18,6 +18,7 @@ using IO.Swagger.Attributes; using IO.Swagger.Security; using Microsoft.AspNetCore.Authorization; using IO.Swagger.DTO; +using IO.Swagger.Enum; namespace IO.Swagger.Controllers { diff --git a/EPAServeur/Controllers/EngagementsApi.cs b/EPAServeur/Controllers/EngagementsApi.cs index 44a9e21..6812cdc 100644 --- a/EPAServeur/Controllers/EngagementsApi.cs +++ b/EPAServeur/Controllers/EngagementsApi.cs @@ -18,6 +18,7 @@ using IO.Swagger.Attributes; using IO.Swagger.Security; using Microsoft.AspNetCore.Authorization; using IO.Swagger.DTO; +using IO.Swagger.Enum; namespace IO.Swagger.Controllers { diff --git a/EPAServeur/IServices/ICollaborateurService.cs b/EPAServeur/IServices/ICollaborateurService.cs index 3a43321..3b30e43 100644 --- a/EPAServeur/IServices/ICollaborateurService.cs +++ b/EPAServeur/IServices/ICollaborateurService.cs @@ -15,10 +15,6 @@ namespace EPAServeur.IServices Task GetCollaborateurByIdAsync(Guid? id); CollaborateurDTO GetCollaborateurByMail(string mail); Task GetCollaborateurByMailAsync(string mail); - ProfilDTO GetProfilById(Guid? idCollaborateur); - Task GetProfilByIdAsync(Guid? idCollaborateur); - ProfilDTO GetProfilByMail(string mail); - Task GetProfilByMailAsync(string mail); IEnumerable GetCollaborateurs(bool? asc, int? numPage, int? parPage, List fonctions, long? idAgence, long? idBU, string texte, string tri); Task> GetCollaborateursAsync(bool? asc, int? numPage, int? parPage, List fonctions, long? idAgence, long? idBU, string texte, string tri); IEnumerable GetCollaborateursByReferent(Guid? idReferent, bool? asc, int? numPage, int? parPage, string texte, string tri); diff --git a/EPAServeur/IServices/IReferentEPService.cs b/EPAServeur/IServices/IReferentEPService.cs new file mode 100644 index 0000000..f228004 --- /dev/null +++ b/EPAServeur/IServices/IReferentEPService.cs @@ -0,0 +1,14 @@ +using EPAServeur.Context; +using IO.Swagger.DTO; +using IO.Swagger.ModelCollaborateur; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace EPAServeur.IServices +{ + public interface IReferentEPService + { + } +} diff --git a/EPAServeur/IServices/IReferentService.cs b/EPAServeur/IServices/IReferentService.cs deleted file mode 100644 index 8cb68cb..0000000 --- a/EPAServeur/IServices/IReferentService.cs +++ /dev/null @@ -1,24 +0,0 @@ -using EPAServeur.Context; -using IO.Swagger.DTO; -using IO.Swagger.ModelCollaborateur; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace EPAServeur.IServices -{ - public interface IReferentService - { - ReferentDTO GetReferentById(Guid? idReferent); - Task GetReferentByIdAsync(Guid? idReferent); - ReferentDTO GetReferentActuelCollaborateur(Guid? idCollaborateur); - Task GetReferentActuelCollaborateurAsync(Guid? idCollaborateur); - IEnumerable GetReferents(bool? asc, int? numPage, int? parPAge, List fonctions, long? idAgence, long? idBU, string texte, string tri); - Task> GetReferentsAsync(bool? asc, int? numPage, int? parPAge, List fonctions, long? idAgence, long? idBU, string texte, string tri); - - IEnumerable GetReferentsByCollaborateur(bool? asc, Guid? idCollaborateur, int? numPage, int? parPAge, string texte, string tri); - Task> GetReferentsByCollaborateurAsync(bool? asc, Guid? idCollaborateur, int? numPage, int? parPAge, string texte, string tri); - - } -} diff --git a/EPAServeur/Services/CollaborateurService.cs b/EPAServeur/Services/CollaborateurService.cs index 2b4286b..7844c53 100644 --- a/EPAServeur/Services/CollaborateurService.cs +++ b/EPAServeur/Services/CollaborateurService.cs @@ -249,95 +249,12 @@ namespace EPAServeur.Services return collaborateursDTO; } - /// - /// Récupérer le profil d'un collaborateur par mail - /// - /// mail du collaborateur dont on cherche le profil - /// Renvoie le profil correspondant au mail passé en paramètre - public ProfilDTO GetProfilByMail(string mail) - { - Collaborateur collaborateur = collaborateurApi.ChercherCollabMail(mail); - if (collaborateur == null) - throw new CollaborateurNotFoundException(); - return GetProfilDTO(collaborateur); - } - - /// - /// Récupérer le profil d'un collaborateur par mail de manière asynchrone - /// - /// mail du collaborateur dont on cherche le profil - /// Renvoie le profil correspondant au mail passé en paramètre - public async Task GetProfilByMailAsync(string mail) - { - Collaborateur collaborateur = await collaborateurApi.ChercherCollabMailAsync(mail); - if (collaborateur == null) - throw new CollaborateurNotFoundException(); - return GetProfilDTO(collaborateur); - } - - /// - /// Récupérer un profil d'un collaborateur par l'id - /// - /// id du collaborateur dont on cherche le profil - /// Renvoie le profil correspondant à l'id passé en paramètre - public ProfilDTO GetProfilById(Guid? idCollaborateur) - { - //Stopwatch stopwatch = new Stopwatch(); - //stopwatch.Start(); - Collaborateur collaborateur = collaborateurApi.ChercherCollabId(idCollaborateur); - //stopwatch.Stop(); - //Console.WriteLine("Durée d'exécution GetProfil: {0}", stopwatch.Elapsed.TotalSeconds); - //stopwatch.Restart(); - //stopwatch.Stop(); - //Console.WriteLine("Durée d'exécution numéro 1: {0}", stopwatch.Elapsed.TotalSeconds); - - if (collaborateur == null) - throw new CollaborateurNotFoundException(); - return GetProfilDTO(collaborateur); - } - - /// - /// Récupérer un profil d'un collaborateur par l'id de manière asynchrone - /// - /// id du collaborateur dont on cherche le profil - /// Renvoie le profil correspondant à l'id passé en paramètre - public async Task GetProfilByIdAsync(Guid? idCollaborateur) - { - //Stopwatch stopwatch = new Stopwatch(); - //stopwatch.Start(); - Collaborateur collaborateur = await collaborateurApi.ChercherCollabIdAsync(idCollaborateur); - //stopwatch.Stop(); - //Console.WriteLine("Durée d'exécution GetProfil: {0}", stopwatch.Elapsed.TotalSeconds); - //stopwatch.Restart(); - //stopwatch.Stop(); - //Console.WriteLine("Durée d'exécution numéro 1: {0}", stopwatch.Elapsed.TotalSeconds); - - if (collaborateur == null) - throw new CollaborateurNotFoundException(); - return GetProfilDTO(collaborateur); - } + #endregion #region DTO To Object - /// - /// Transformer un objet collaborateur en ProfilDTO - /// - /// collaborateur a transformé en profilDTO - /// Renvoie le profil associé au collaborateur passé en paramètre - private ProfilDTO GetProfilDTO(Collaborateur collaborateur) - { - ProfilDTO profilDTO = new ProfilDTO() - { - Id = collaborateur.Id, - DateArrivee = collaborateur.DateArrivee, - MailApside = collaborateur.MailApside, - Nom = collaborateur.Nom, - Prenom = collaborateur.Prenom, - BusinessUnit = GetBusinessUnitDTO(collaborateur.BusinessUnit) - }; - return profilDTO; - } + /// /// Transformer une agence en agenceDTO @@ -397,29 +314,10 @@ namespace EPAServeur.Services }; collaborateurDTO.BusinessUnit = GetBusinessUnitDTO(collaborateur.BusinessUnit); - collaborateurDTO.Referent = GetReferentDTO(collaborateur.Referent); + //collaborateurDTO.Referent = GetReferentDTO(collaborateur.Referen return collaborateurDTO; } - - /// - /// Transforme un referent en referentDTO - /// - /// referent à transformer en referentDTO - /// Renvoie la transformation DTO du referent - private 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; - } #endregion } } diff --git a/EPAServeur/Services/EngagementService.cs b/EPAServeur/Services/EngagementService.cs index 2788ac7..867c56e 100644 --- a/EPAServeur/Services/EngagementService.cs +++ b/EPAServeur/Services/EngagementService.cs @@ -22,7 +22,7 @@ namespace EPAServeur.Services private readonly EpContext epContext; private readonly ICollaborateurService collaborateurService; - private readonly IReferentService referentService; + private readonly IReferentEPService referentService; #endregion #region Contructeurs @@ -31,7 +31,7 @@ namespace EPAServeur.Services /// Constructeur de la classe EngagementService /// /// - public EngagementService(EpContext _epContext, ICollaborateurService _collaborateurService, IReferentService _referentService) + public EngagementService(EpContext _epContext, ICollaborateurService _collaborateurService, IReferentEPService _referentService) { epContext = _epContext; collaborateurService = _collaborateurService; @@ -333,12 +333,12 @@ namespace EPAServeur.Services EpInformationDTO epInformationDTO = new EpInformationDTO() { Id = ep.IdEP, - Type = ep.TypeEP.ToString(), - Statut = ep.Statut.ToString(), + Type = ep.TypeEP, + Statut = ep.Statut, DatePrevisionnelle = ep.DatePrevisionnelle, Obligatoire = ep.Obligatoire, Collaborateur = collaborateurService.GetCollaborateurById(ep.IdCollaborateur), - Referent = referentService.GetReferentById(ep.IdReferent) + //Referent = referentService.GetReferentById(ep.IdReferent) //Ajouter la date de disponibilité }; @@ -355,14 +355,14 @@ namespace EPAServeur.Services EpInformationDTO epInformationDTO = new EpInformationDTO() { Id = ep.IdEP, - Type = ep.TypeEP.ToString(), - Statut = ep.Statut.ToString(), + Type = ep.TypeEP, + Statut = ep.Statut, DatePrevisionnelle = ep.DatePrevisionnelle, Obligatoire = ep.Obligatoire //Ajouter la date de disponibilité }; var collaborateur = collaborateurService.GetCollaborateurByIdAsync(ep.IdCollaborateur); - var referent = referentService.GetReferentByIdAsync(ep.IdReferent); + var referent = collaborateurService.GetCollaborateurByIdAsync(ep.IdReferent); await Task.WhenAll(collaborateur, referent); @@ -407,16 +407,11 @@ namespace EPAServeur.Services if (epInformationDTO == null) return null; - // Traiter - Enum.TryParse(epInformationDTO.Type, out TypeEp typeEP); - - Enum.TryParse(epInformationDTO.Statut, out StatutEp statutEP); - Ep ep = new Ep() { IdEP = epInformationDTO.Id.Value, - TypeEP = typeEP, - Statut = statutEP, + TypeEP = epInformationDTO.Type, + Statut = epInformationDTO.Statut, DatePrevisionnelle = epInformationDTO.DatePrevisionnelle.Value, Obligatoire = epInformationDTO.Obligatoire.Value, IdReferent = epInformationDTO.Referent.Id.Value, diff --git a/EPAServeur/Services/NoteService.cs b/EPAServeur/Services/NoteService.cs index 7806ca4..5a01e3c 100644 --- a/EPAServeur/Services/NoteService.cs +++ b/EPAServeur/Services/NoteService.cs @@ -66,12 +66,12 @@ namespace EPAServeur.Services { //Stopwatch stopwatch = new Stopwatch(); //stopwatch.Start(); - if (collaborateurService.GetProfilById(idAuteur) == null) + if (collaborateurService.GetCollaborateurById(idAuteur) == null) throw new ReferentNotFoundException(); //stopwatch.Stop(); //Console.WriteLine("Durée d'exécution GetProfil 1: {0}", stopwatch.Elapsed.TotalSeconds); //stopwatch.Restart(); - if (collaborateurService.GetProfilById(idAuteur) == null || collaborateurService.GetProfilById(idCollaborateur) == null) + if (collaborateurService.GetCollaborateurById(idAuteur) == null || collaborateurService.GetCollaborateurById(idCollaborateur) == null) throw new CollaborateurNotFoundException(); //stopwatch.Stop(); //Console.WriteLine("Durée d'exécution GetProfil 2: {0}", stopwatch.Elapsed.TotalSeconds); @@ -208,7 +208,7 @@ namespace EPAServeur.Services IdCollaborateur = note.IdCollaborateur, Collaborateur = collaborateur.Prenom + collaborateur.Nom, Titre = note.Titre, - DateMiseAjour = note.DateMiseAJour + DateMiseAJour = note.DateMiseAJour }; return affichage; } diff --git a/EPAServeur/Services/ReferentEPService.cs b/EPAServeur/Services/ReferentEPService.cs new file mode 100644 index 0000000..830a7a3 --- /dev/null +++ b/EPAServeur/Services/ReferentEPService.cs @@ -0,0 +1,17 @@ +using EPAServeur.Exceptions; +using EPAServeur.IServices; +using IO.Swagger.ApiCollaborateur; +using IO.Swagger.DTO; +using IO.Swagger.ModelCollaborateur; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace EPAServeur.Services +{ + public class ReferentEPService : IReferentEPService + { + + } +} diff --git a/EPAServeur/Services/ReferentService.cs b/EPAServeur/Services/ReferentService.cs deleted file mode 100644 index 605d559..0000000 --- a/EPAServeur/Services/ReferentService.cs +++ /dev/null @@ -1,414 +0,0 @@ -using EPAServeur.Exceptions; -using EPAServeur.IServices; -using IO.Swagger.ApiCollaborateur; -using IO.Swagger.DTO; -using IO.Swagger.ModelCollaborateur; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace EPAServeur.Services -{ - public class ReferentService : IReferentService - { - #region Variables - // private readonly IReferentApi referentApi; - private readonly ICollaborateurApi collaborateurApi; - #endregion - - #region Contructeurs - public ReferentService(ICollaborateurApi _collaborateurApi) - { - //referentApi = _referentApi; - collaborateurApi = _collaborateurApi; - } - - #endregion - - #region Méthodes Service - - /// - /// Récupère un référent par son id - /// - /// - /// - public ReferentDTO GetReferentById(Guid? idReferent) - { - Collaborateur referent = collaborateurApi.ChercherCollabId(idReferent); - - if (referent == null) - throw new ReferentNotFoundException(); - - return GetReferentDTO(referent); - } - - /// - /// Récupère un référent par son id de manière asynchrone - /// - /// - /// - public async Task GetReferentByIdAsync(Guid? idReferent) - { - Collaborateur referent = await collaborateurApi.ChercherCollabIdAsync(idReferent); - - if (referent == null) - throw new ReferentNotFoundException(); - - return GetReferentDTO(referent); - } - - /// - /// Récupère un référent en fonction d'un collaborateur - /// - /// - /// - public ReferentDTO GetReferentActuelCollaborateur(Guid? idCollaborateur) - { - Collaborateur referent = collaborateurApi.ChercherRefActuelId(idCollaborateur); - - if (referent == null) - throw new ReferentNotFoundException(); - - return GetReferentDTO(referent); - } - - /// - /// Récupère un référent en fonction d'un collaborateur de manière asynchrone - /// - /// - /// - public async Task GetReferentActuelCollaborateurAsync(Guid? idCollaborateur) - { - Collaborateur referent = await collaborateurApi.ChercherRefActuelIdAsync(idCollaborateur); - - if (referent == null) - throw new ReferentNotFoundException(); - - return GetReferentDTO(referent); - } - - /// - /// Récupère la liste des référents pour une agence - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public IEnumerable GetReferents(bool? asc, int? numPage, int? parPAge, List fonctions, long? idAgence, long? idBU, string texte, string tri) - { - throw new NotImplementedException(); - - ////IEnumerable collaborateurs; // A changer (Sera utilisé pour récupérer la liste des référents par fonction - //IEnumerable referents = null; // A changer - //IEnumerable referentDTOs = null; // A changer - ////List 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(); - - //referentDTOs = referents.Where(referent => (referent.Nom + " " + referent.Prenom).ToLower().Contains(texte) || (referent.Prenom + " " + referent.Nom).ToLower().Contains(texte)).Select(referent => GetReferentDTO(referent)); - - //return referentDTOs; - } - - /// - /// Récupère la liste des référents pour une agence de manière asynchrone - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - - public async Task> GetReferentsAsync(bool? asc, int? numPage, int? parPAge, List fonctions, long? idAgence, long? idBU, string texte, string tri) - { - throw new NotImplementedException(); - - //IEnumerable referents = null ; // A changer - //IEnumerable referentDTOs = null; // A changer - - //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(); - - //referentDTOs = referents.Where(referent => (referent.Nom + " " + referent.Prenom).ToLower().Contains(texte) || (referent.Prenom + " " + referent.Nom).ToLower().Contains(texte)).Select(referent => GetReferentDTO(referent)); - - //return referentDTOs; - } - - - /// - /// Récupère la liste des référents pour un collaborateur - /// - /// - /// - /// - /// - /// - /// - /// - public IEnumerable GetReferentsByCollaborateur(bool? asc, Guid? idCollaborateur, int? numPage, int? parPAge, string texte, string tri) - { - IEnumerable referents; - IEnumerable 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(); - - Collaborateur collaborateur = collaborateurApi.ChercherCollabId(idCollaborateur); - - if (collaborateur == null) - throw new CollaborateurNotFoundException(); - - referents = collaborateurApi.ChercherRefCollabId(idCollaborateur); - - if (referents == null) - return new List(); - - referentDTOs = referents.Where(referent => (referent.Nom + " " + referent.Prenom).ToLower().Contains(texte) || (referent.Prenom + " " + referent.Nom).ToLower().Contains(texte)).Select(referent => GetReferentDTO(referent)); - - return referentDTOs; - } - - /// - /// Récupère la liste des référents pour un collaborateur de manère asynchrone - /// - /// - /// - /// - /// - /// - /// - /// - public async Task> GetReferentsByCollaborateurAsync(bool? asc, Guid? idCollaborateur, int? numPage, int? parPAge, string texte, string tri) - { - IEnumerable referents; - IEnumerable 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(); - - Collaborateur collaborateur = await collaborateurApi.ChercherCollabIdAsync(idCollaborateur); - - if (collaborateur == null) - throw new CollaborateurNotFoundException(); - - referents = await collaborateurApi.ChercherRefCollabIdAsync(idCollaborateur); - - if (referents == null) - return new List(); - - 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 - - #region Object to DTO - - /// - /// Récupère un objet AgenceDTO en fonction d'un objet Agence - /// - /// - /// - private AgenceDTO GetAgenceDTO(Agence agence) - { - if (agence == null) - return null; - AgenceDTO agenceDTO = new AgenceDTO() - { - Id = agence.Id, - Nom = agence.Nom, - Bu = new List() - }; - agenceDTO.Bu = agence.Bus.Select(bu => new BusinessUnitDTO() - { - Id = bu.Id, - Nom = bu.Nom - }).ToList(); - return agenceDTO; - } - - /// - /// Récupère un objet BusinessUnitDTO en fonction d'un objet BU - /// - /// - /// - private 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; - } - - /// - /// Récupère un objet CollaborateurDTO en fonction d'un objet Collaborateur - /// - /// - /// - private 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; - } - - /// - /// Récupère un objet ReferentDTO en fonction d'un objet Referent - /// - /// - /// - private 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; - } - - - #endregion - - #region DTO to Object - - #endregion - - #endregion - - - - - } -} diff --git a/EPAServeur/Startup.cs b/EPAServeur/Startup.cs index 515adf4..887dfc8 100644 --- a/EPAServeur/Startup.cs +++ b/EPAServeur/Startup.cs @@ -122,7 +122,7 @@ namespace EPAServeur services.AddScoped(); services.AddScoped(); services.AddScoped(); - services.AddScoped(); + services.AddScoped(); services.AddScoped(); //Handlers