Compare commits

...

11 Commits

  1. 286
      EPAServeur.Tests/Services/EpDetailsServiceTests.cs
  2. 343
      EPAServeur/Context/DataSeeder.cs
  3. 4
      EPAServeur/Context/EpContext.cs
  4. 41
      EPAServeur/DTO/CommentaireAssistantDTO.cs
  5. 64
      EPAServeur/DTO/EpDTO.cs
  6. 2
      EPAServeur/DTO/TypeEntretienDTO.cs
  7. 31
      EPAServeur/Exceptions/EpNotFoundException.cs
  8. 17
      EPAServeur/IServices/ITransformDTO.cs
  9. 4
      EPAServeur/Models/EP/ChoixTypeEntretien.cs
  10. 2
      EPAServeur/Models/EP/ParticipationEP.cs
  11. 55
      EPAServeur/Services/EpDetailsService.cs
  12. 178
      EPAServeur/Services/TransformDTO.cs

@ -0,0 +1,286 @@
using EPAServeur.Context;
using EPAServeur.Exceptions;
using EPAServeur.IServices;
using EPAServeur.Models.EP;
using EPAServeur.Services;
using IO.Swagger.ApiCollaborateur;
using IO.Swagger.DTO;
using IO.Swagger.Enum;
using Microsoft.EntityFrameworkCore;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace EPAServeur.Tests.Services
{
public class EpDetailsServiceTests
{
#region variables
private EpContext context;
private ICollaborateurService collaborateurService;
private ITransformDTO transformDTO;
#endregion
#region Setup
[SetUp]
public void Setup()
{
// Utilisation d'une base de données en mémoire
var optionBuider = new DbContextOptionsBuilder<EpContext>()
.UseInMemoryDatabase("server_ep_test")
.Options;
context = new EpContext(optionBuider);
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
context.SaveChanges();
DataSeeder.AddTypesEntretien(context);
DataSeeder.AddEp(context);
foreach (var entity in context.ChangeTracker.Entries())
{
entity.State = EntityState.Detached;
}
transformDTO = new TransformDTO();
collaborateurService = new CollaborateurService(new CollaborateurApi(), context, transformDTO);
}
#endregion
#region Récupérer EP simple
[TestCase(1, "301ba7f3-095e-4912-8998-a7c942dc5f23", StatutEp.Disponible)]
[TestCase(2, "e7820f92-eab1-42f5-ae96-5c16e71ff1e6", StatutEp.DatesProposees)]
[TestCase(5, "17b87130-0e9d-4b78-b0e3-a11e5f70318d", StatutEp.AttenteEntretien)]
[TestCase(14, "a0f40e2a-cc03-4032-a627-5389e1281c64", StatutEp.Signe)]
public async Task GetEpById(long idEP, Guid? idCollaborateur, StatutEp statutEp)
{
Ep ep = await context.Ep.FindAsync(idEP);
Assert.IsNotNull(ep);
Assert.AreEqual(idEP, ep.IdEP);
Assert.AreEqual(idCollaborateur, ep.IdCollaborateur);
Assert.AreEqual(statutEp, ep.Statut);
IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService);
EpDTO epDTO = await epDetailsService.GetEp(ep.IdEP);
Assert.IsNotNull(epDTO);
Assert.AreEqual(epDTO.Collaborateur.Id, ep.IdCollaborateur);
Assert.AreEqual(epDTO.Statut, ep.Statut);
Assert.AreEqual(epDTO.Id, ep.IdEP);
}
#endregion
#region Récupérer EP exceptions
[TestCase(-999)]
[TestCase(20)]
[TestCase(100)]
[TestCase(0)]
public void GetEPById_NotFoundException(long idEp)
{
IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService);
AsyncTestDelegate exception = () => epDetailsService.GetEp(idEp);
Assert.ThrowsAsync(typeof(EpNotFoundException), exception);
}
#endregion
#region Récupérer EP avec Engagements
[TestCase(6, 3)]
[TestCase(8, 0)]
[TestCase(10, 1)]
public async Task GetEPById_GetEngagement(long idEP, int count)
{
IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService);
EpDTO epDTO = await epDetailsService.GetEp(idEP);
if(count == 0)
{
Assert.IsNull(epDTO.Engagements);
}
else
{
Assert.IsNotNull(epDTO.Engagements);
Assert.AreEqual(count, epDTO.Engagements.Count);
}
}
#endregion
#region Récupérer EP avec participant EP
[TestCase(1,0)]
[TestCase(3,2)]
[TestCase(5,1)]
[TestCase(11,2)]
public async Task GetEpById_GetParticipantEP(long idEP, int count)
{
IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService);
EpDTO epDTO = await epDetailsService.GetEp(idEP);
if (count == 0)
{
Assert.IsNull(epDTO.Participants);
}
else
{
Assert.IsNotNull(epDTO.Participants);
Assert.AreEqual(count, epDTO.Participants.Count);
}
}
#endregion
#region Récupérer EP avec CommentaireAssistant
[TestCase(2, 2)]
[TestCase(4, 0)]
[TestCase(16, 1)]
public async Task GetEpById_GetCommentairesAssistant(long idEP, int count)
{
IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService);
EpDTO epDTO = await epDetailsService.GetEp(idEP);
if (count == 0)
{
Assert.IsNull(epDTO.CommentairesAssistant);
}
else
{
Assert.IsNotNull(epDTO.CommentairesAssistant);
Assert.AreEqual(count, epDTO.CommentairesAssistant.Count);
}
}
#endregion
#region Récupérer EP avec demandes de délégation
[TestCase(1, false)]
[TestCase(2, true)]
[TestCase(4, true)]
[TestCase(8, true)]
[TestCase(9, false)]
[TestCase(12, false)]
public async Task GetEpById_GetDemandeDelegation(long idEp, bool possedeDemandeDelegation)
{
IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService);
EpDTO epDTO = await epDetailsService.GetEp(idEp);
if(possedeDemandeDelegation)
Assert.IsNotNull(epDTO.DemandesDelegation);
else
Assert.IsNull(epDTO.DemandesDelegation);
}
#endregion
#region Récupérer EP avec RDV entretiens
[TestCase(2)]
[TestCase(5)]
[TestCase(12)]
public async Task GetEp_GetRDVEntretien(long idEp)
{
IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService);
EpDTO epDTO = await epDetailsService.GetEp(idEp);
Assert.IsNotNull(epDTO);
Assert.IsNotNull(epDTO.RdvEntretien);
Assert.IsNotNull(epDTO.RdvEntretien.DateEntretien);
}
[TestCase(1, 0)]
[TestCase(2, 3)]
[TestCase(5, 2)]
[TestCase(11, 0)]
[TestCase(13, 0)]
public async Task GetEp_GetPropositionRDVEntretien(long idEp, int count)
{
IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService);
EpDTO epDTO = await epDetailsService.GetEp(idEp);
Assert.IsNotNull(epDTO);
if( count == 0)
{
Assert.IsNull(epDTO.PropositionsEntretien);
}
else
{
Assert.IsNotNull(epDTO.PropositionsEntretien);
Assert.AreEqual(epDTO.PropositionsEntretien.Count, count);
Assert.IsTrue(epDTO.PropositionsEntretien.Count <= 3);
Assert.IsTrue(epDTO.PropositionsEntretien.Count > 0);
Assert.Less(epDTO.Statut, StatutEp.Effectue);
}
}
#endregion
#region Récupérer EP avec choix type entretien
[TestCase(1, 0)]
[TestCase(2, 4)]
[TestCase(4, 1)]
[TestCase(5, 2)]
[TestCase(10, 0)]
[TestCase(12, 0)]
public async Task GetEp_GetChoixTypeEntretien(long idEp, int count)
{
IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService);
EpDTO epDTO = await epDetailsService.GetEp(idEp);
Assert.IsNotNull(epDTO);
if (count == 0)
{
Assert.IsNull(epDTO.ChoixTypeEntretien);
}
else
{
Assert.IsNotNull(epDTO.ChoixTypeEntretien);
Assert.AreEqual(epDTO.ChoixTypeEntretien.Count, count);
Assert.Less(epDTO.Statut, StatutEp.Effectue);
}
}
#endregion
#region Objectifs
[TestCase(3, true)]
[TestCase(7, false)]
[TestCase(10, true)]
public async Task GetEp_Objectifs_ObjectifsPrecedents(long idEp, bool possedeObjectifsPref)
{
IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService);
EpDTO epDTO = await epDetailsService.GetEp(idEp);
Assert.IsNotNull(epDTO);
Assert.IsNotNull(epDTO.Objectifs);
Assert.AreEqual(3, epDTO.Objectifs.Count);
if (possedeObjectifsPref)
{
Assert.IsNotNull(epDTO.ObjectifsPrecedent);
Assert.AreEqual(3, epDTO.ObjectifsPrecedent.Count);
}else
{
Assert.IsNull(epDTO.ObjectifsPrecedent);
}
}
#endregion
#region Demande EPI
[TestCase(4)]
[TestCase(8)]
[TestCase(13)]
public async Task GetEp_GetDemandeEPI(long idEp)
{
IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService);
EpDTO epDTO = await epDetailsService.GetEp(idEp);
Assert.IsNotNull(epDTO);
Assert.IsNotNull(epDTO.DemandeEPI);
Assert.IsTrue(epDTO.Collaborateur.Id.Equals(epDTO.DemandeEPI.Collaborateur.Id));
Assert.AreEqual(epDTO.DemandeEPI.EtatDemande, EtatDemande.Validee);
}
#endregion
#region Récupérer EP avec demandes de formation
#endregion
#region
#endregion
#region
#endregion
}
}

@ -63,16 +63,16 @@ namespace EPAServeur.Context
//TypeEntretien
TypeEntretien typeSite, typeClient, typeVisio, typeTelephone;
typeSite = new TypeEntretien { Libelle = "Sur site" };
typeSite = new TypeEntretien { IdTypeEntretien = 1, Libelle = "Sur site" };
epContext.TypeEntretien.Add(typeSite);
typeClient = new TypeEntretien { Libelle = "Chez le client" };
typeClient = new TypeEntretien { IdTypeEntretien = 2, Libelle = "Chez le client" };
epContext.TypeEntretien.Add(typeClient);
typeVisio = new TypeEntretien { Libelle = "Visioconférence" };
typeVisio = new TypeEntretien { IdTypeEntretien = 3, Libelle = "Visioconférence" };
epContext.TypeEntretien.Add(typeVisio);
typeTelephone = new TypeEntretien { Libelle = "Téléphonique" };
typeTelephone = new TypeEntretien { IdTypeEntretien = 4, Libelle = "Téléphonique" };
epContext.TypeEntretien.Add(typeTelephone);
epContext.SaveChanges();
@ -84,9 +84,32 @@ namespace EPAServeur.Context
/// <param name="epContext"></param>
public static void AddEp(EpContext epContext)
{
TypeEntretien typeSite, typeClient, typeVisio, typeTelephone;
typeSite = epContext.TypeEntretien.Find((long)1);
typeClient = epContext.TypeEntretien.Find((long)2);
typeVisio = epContext.TypeEntretien.Find((long)3);
typeTelephone = epContext.TypeEntretien.Find((long)4);
Engagement eg1, eg2, eg3, eg4;
ParticipationEP p1, p2, p3, p4, p5;
CommentaireAssistant ca1, ca2, ca3;
DemandeDelegation dm1, dm2, dm3;
RdvEntretien rdv1, rdv2, rdv3;
RdvEntretien proposition1, proposition2, proposition3;
ChoixTypeEntretien choix1, choix2, choix3, choix4, choix5, choix6, choix7;
Objectif objectif1, objectif2, objectif3, objectif4, objectif5, objectif6, objectif7, objectif8, objectif9;
ObjectifPrecedent objectifPrecedent1, objectifPrecedent2, objectifPrecedent3, objectifPrecedent4, objectifPrecedent5, objectifPrecedent6;
DemandeEPI demandeEPI1, demandeEPI2, demandeEPI3;
//Ep en cours
Ep epEnCours1, epEnCours2, epEnCours3, epEnCours4, epEnCours5, epEnCours6, epEnCours7, epEnCours8, epEnCours9;
//Tours
epEnCours1 = new Ep()
{
@ -114,6 +137,82 @@ namespace EPAServeur.Context
IdCollaborateur = new Guid("e7820f92-eab1-42f5-ae96-5c16e71ff1e6"),
Obligatoire = false,
};
ca1 = new CommentaireAssistant()
{
Commentaire = "Commentaire assistant",
IdAssistant = new Guid("a43b6f4f-f199-4dd0-93b6-a1cb2c0a0d14"),
Ep = epEnCours2
};
ca2 = new CommentaireAssistant()
{
Commentaire = "Commentaire assistant",
IdAssistant = new Guid("a29d707c-5d82-4c48-bed1-a6d1c1710047"),
Ep = epEnCours2
};
epEnCours2.CommentairesAssistant = new List<CommentaireAssistant>(new[] { ca1, ca2 });
dm1 = new DemandeDelegation()
{
DateDemande = DateTime.Now,
Ep = epEnCours1,
IdReferent = new Guid("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d"),
EtatDemande = EtatDemande.EnAttente,
RaisonDemande = "Raison quelconque 1"
};
epEnCours2.DemandeDelegation = dm1;
rdv1 = new RdvEntretien()
{
IdRdvEntretien = 1,
DateEntretien = new DateTime(),
EpChoixRDV = epEnCours2,
TypeEntretien = typeClient,
EpProposition = epEnCours2
};
epEnCours2.RdvEntretien = rdv1;
proposition1 = new RdvEntretien()
{
DateEntretien = new DateTime(),
EpProposition = epEnCours2,
IdRdvEntretien = 2,
TypeEntretien = typeSite
};
proposition2 = new RdvEntretien()
{
DateEntretien = new DateTime(),
EpProposition = epEnCours2,
IdRdvEntretien = 3,
TypeEntretien = typeVisio
};
epEnCours2.PropositionsRDV = new List<RdvEntretien>(new[] { rdv1, proposition1, proposition2 });
choix1 = new ChoixTypeEntretien()
{
Ep = epEnCours2,
Ordre = 0,
TypeEntretien = typeClient
};
choix2 = new ChoixTypeEntretien()
{
Ep = epEnCours2,
Ordre = 1,
TypeEntretien = typeSite
};
choix3 = new ChoixTypeEntretien()
{
Ep = epEnCours2,
Ordre = 2,
TypeEntretien = typeVisio
};
choix4 = new ChoixTypeEntretien()
{
Ep = epEnCours2,
Ordre = 3,
TypeEntretien = typeTelephone
};
epEnCours2.ChoixTypeEntretien = new List<ChoixTypeEntretien>() { choix1, choix2, choix3, choix4 };
epContext.Ep.Add(epEnCours2);
@ -129,6 +228,34 @@ namespace EPAServeur.Context
IdCollaborateur = new Guid("b5254c6c-7caa-435f-a4bb-e0cf92559832"),
Obligatoire = false,
};
p1 = new ParticipationEP()
{
Ep = epEnCours3,
IdParticipant = new Guid("eb8b0f33-f529-4985-861e-1207f3312bb5"),
EstPermanente = false
};
p2 = new ParticipationEP()
{
Ep = epEnCours3,
IdParticipant = new Guid("d4fc247b-015a-44d6-8f3e-a52f0902d2bf"),
EstPermanente = false
};
epEnCours3.Participants = new List<ParticipationEP>(new[] { p1, p2 });
objectif1 = new Objectif() { Ep = epEnCours3, Libelle = "Objectif1" };
objectif2 = new Objectif() { Ep = epEnCours3, Libelle = "Objectif2" };
objectif3 = new Objectif() { Ep = epEnCours3, Libelle = "Objectif3" };
objectifPrecedent1 = new ObjectifPrecedent() { Ep = epEnCours3, Libelle = "ObjectifPrec1", Commentaire = "Commentaire", StatutObjectif = StatutObjectif.Atteint };
objectifPrecedent2 = new ObjectifPrecedent() { Ep = epEnCours3, Libelle = "ObjectifPrec2", Commentaire = "Commentaire", StatutObjectif = StatutObjectif.Partiel };
objectifPrecedent3 = new ObjectifPrecedent() { Ep = epEnCours3, Libelle = "ObjectifPrec3", Commentaire = "Commentaire", StatutObjectif = StatutObjectif.Partiel };
epEnCours3.Objectifs = new List<Objectif>() { objectif1, objectif2, objectif3 };
epEnCours3.ObjectifsPrecedents = new List<ObjectifPrecedent>() { objectifPrecedent1, objectifPrecedent2, objectifPrecedent3 };
epContext.Ep.Add(epEnCours3);
epEnCours4 = new Ep()
@ -143,6 +270,36 @@ namespace EPAServeur.Context
IdCollaborateur = new Guid("a0f40e2a-cc03-4032-a627-5389e1281c64"),
Obligatoire = false,
};
dm2 = new DemandeDelegation()
{
DateDemande = DateTime.Now,
Ep = epEnCours4,
IdReferent = new Guid("d4fc247b-015a-44d6-8f3e-a52f0902d2bf"),
EtatDemande = EtatDemande.EnAttente,
RaisonDemande = "Raison quelconque 2"
};
demandeEPI1 = new DemandeEPI()
{
IdReferent = new Guid("eb8b0f33-f529-4985-861e-1207f3312bb5"),
Ep = epEnCours4,
DateDemande = new DateTime(),
DateReponse = new DateTime(),
EtatDemande = EtatDemande.Validee,
IdCollaborateur = new Guid("a0f40e2a-cc03-4032-a627-5389e1281c64")
};
epEnCours4.DemandeEPI = demandeEPI1;
epEnCours4.DemandeDelegation = dm2;
choix5 = new ChoixTypeEntretien()
{
Ep = epEnCours4,
Ordre = 0,
TypeEntretien = typeSite
};
epEnCours4.ChoixTypeEntretien = new List<ChoixTypeEntretien>() { choix5 };
epContext.Ep.Add(epEnCours4);
epEnCours5 = new Ep()
@ -157,6 +314,54 @@ namespace EPAServeur.Context
IdCollaborateur = new Guid("17b87130-0e9d-4b78-b0e3-a11e5f70318d"),
Obligatoire = true,
};
p3 = new ParticipationEP()
{
Ep = epEnCours5,
IdParticipant = new Guid("d4fc247b-015a-44d6-8f3e-a52f0902d2bf"),
EstPermanente = false
};
epEnCours5.Participants = new List<ParticipationEP>(new[] { p3 });
rdv2 = new RdvEntretien()
{
DateEntretien = new DateTime(),
EpProposition = epEnCours5,
IdRdvEntretien = 4,
TypeEntretien = typeSite,
EpChoixRDV = epEnCours5
};
proposition3 = new RdvEntretien()
{
DateEntretien = new DateTime(),
EpProposition = epEnCours5,
IdRdvEntretien = 5,
TypeEntretien = typeVisio
};
epEnCours5.PropositionsRDV = new List<RdvEntretien>(new[] { rdv2, proposition3 });
epEnCours5.RdvEntretien = rdv2;
choix6 = new ChoixTypeEntretien()
{
Ep = epEnCours5,
Ordre = 0,
TypeEntretien = typeSite
};
choix7 = new ChoixTypeEntretien()
{
Ep = epEnCours5,
Ordre = 1,
TypeEntretien = typeVisio
};
epEnCours5.ChoixTypeEntretien = new List<ChoixTypeEntretien>() { choix6, choix7 };
epContext.Ep.Add(epEnCours5);
epEnCours6 = new Ep()
@ -171,6 +376,37 @@ namespace EPAServeur.Context
IdCollaborateur = new Guid("de98a866-736f-4295-a669-92a8694e2ee3"),
Obligatoire = false,
};
eg1 = new Engagement()
{
Action = "action",
DateLimite = DateTime.Now,
Dispositif = "dispositif",
EtatEngagement = EtatEngagement.EnAttente,
Modalite = "modalite",
Ep = epEnCours6
};
eg2 = new Engagement()
{
Action = "action",
DateLimite = DateTime.Now,
Dispositif = "dispositif",
EtatEngagement = EtatEngagement.EnAttente,
Modalite = "modalite",
Ep = epEnCours6
};
eg3 = new Engagement()
{
Action = "action",
DateLimite = DateTime.Now,
Dispositif = "dispositif",
EtatEngagement = EtatEngagement.EnAttente,
Modalite = "modalite",
Ep = epEnCours6
};
epEnCours6.Engagements = new List<Engagement>();
epEnCours6.Engagements.Add(eg1);
epEnCours6.Engagements.Add(eg2);
epEnCours6.Engagements.Add(eg3);
epContext.Ep.Add(epEnCours6);
epEnCours7 = new Ep()
@ -185,6 +421,11 @@ namespace EPAServeur.Context
IdCollaborateur = new Guid("4f3fcd23-a1e4-4c9e-afa2-d06ca9216491"),
Obligatoire = false,
};
objectif4 = new Objectif() { Ep = epEnCours7, Libelle = "Objectif4" };
objectif5 = new Objectif() { Ep = epEnCours7, Libelle = "Objectif5" };
objectif6 = new Objectif() { Ep = epEnCours7, Libelle = "Objectif6" };
epEnCours7.Objectifs = new List<Objectif>() { objectif4, objectif5, objectif6 };
epContext.Ep.Add(epEnCours7);
epEnCours8 = new Ep()
@ -200,6 +441,26 @@ namespace EPAServeur.Context
Obligatoire = true,
};
epContext.Ep.Add(epEnCours8);
dm3 = new DemandeDelegation()
{
DateDemande = DateTime.Now,
Ep = epEnCours8,
IdReferent = new Guid("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d"),
EtatDemande = EtatDemande.EnAttente,
RaisonDemande = "Raison quelconque 3"
};
epEnCours8.DemandeDelegation = dm3;
demandeEPI2 = new DemandeEPI()
{
IdReferent = new Guid("ea027734-ff0f-4308-8879-133a09fb3c46"),
Ep = epEnCours8,
DateDemande = new DateTime(),
DateReponse = new DateTime(),
EtatDemande = EtatDemande.Validee,
IdCollaborateur = new Guid("0968ccd3-1ef5-4041-83f3-1c76afb02bbf"),
};
epEnCours8.DemandeEPI = demandeEPI2;
epEnCours9 = new Ep()
{
@ -213,13 +474,14 @@ namespace EPAServeur.Context
IdCollaborateur = new Guid("13fbe621-1bc9-4f04-afde-b54ca076e239"),
Obligatoire = true,
};
epContext.Ep.Add(epEnCours9);
//Ep signés
Ep epSigne1, epSigne2, epSigne3, epSigne4, epSigne5, epSigne6, epSigne7, epSigne8, epSigne9;//, epSigne10, epSigne11, epSigne12, epSigne13, epSigne14;
Ep epSigne1, epSigne2, epSigne3, epSigne4, epSigne5, epSigne6, epSigne7, epSigne8, epSigne9;
epSigne1 = new Ep()
{
DateDisponibilite = new DateTime(2017, 1, 15),
@ -232,6 +494,28 @@ namespace EPAServeur.Context
IdCollaborateur = new Guid("301ba7f3-095e-4912-8998-a7c942dc5f23"),
Obligatoire = true,
};
eg4 = new Engagement()
{
Action = "action",
DateLimite = DateTime.Now,
Dispositif = "dispositif",
EtatEngagement = EtatEngagement.EnAttente,
Modalite = "modalite",
Ep = epSigne1
};
epSigne1.Engagements = new List<Engagement>();
epSigne1.Engagements.Add(eg4);
objectif7 = new Objectif() { Ep = epSigne1, Libelle = "Objectif7" };
objectif8 = new Objectif() { Ep = epSigne1, Libelle = "Objectif8" };
objectif9 = new Objectif() { Ep = epSigne1, Libelle = "Objectif9" };
objectifPrecedent4 = new ObjectifPrecedent() { Ep = epSigne1, Libelle = "ObjectifPrec4", Commentaire = "Commentaire", StatutObjectif = StatutObjectif.NonAtteint };
objectifPrecedent5 = new ObjectifPrecedent() { Ep = epSigne1, Libelle = "ObjectifPrec5", Commentaire = "Commentaire", StatutObjectif = StatutObjectif.NonAtteint };
objectifPrecedent6 = new ObjectifPrecedent() { Ep = epSigne1, Libelle = "ObjectifPrec6", Commentaire = "Commentaire", StatutObjectif = StatutObjectif.Atteint };
epSigne1.Objectifs = new List<Objectif>() { objectif7, objectif8, objectif9 };
epSigne1.ObjectifsPrecedents = new List<ObjectifPrecedent>() { objectifPrecedent4, objectifPrecedent6, objectifPrecedent5 };
epContext.Ep.Add(epSigne1);
epSigne2 = new Ep()
@ -246,6 +530,19 @@ namespace EPAServeur.Context
IdCollaborateur = new Guid("e7820f92-eab1-42f5-ae96-5c16e71ff1e6"),
Obligatoire = false,
};
p4 = new ParticipationEP()
{
Ep = epSigne2,
IdParticipant = new Guid("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d"),
EstPermanente = false
};
p5 = new ParticipationEP()
{
Ep = epSigne2,
IdParticipant = new Guid("eb8b0f33-f529-4985-861e-1207f3312bb5"),
EstPermanente = false
};
epSigne2.Participants = new List<ParticipationEP>(new[] { p4, p5 });
epContext.Ep.Add(epSigne2);
@ -261,8 +558,21 @@ namespace EPAServeur.Context
IdCollaborateur = new Guid("b5254c6c-7caa-435f-a4bb-e0cf92559832"),
Obligatoire = false,
};
rdv3 = new RdvEntretien()
{
IdRdvEntretien = 6,
TypeEntretien = typeVisio,
DateEntretien = new DateTime(),
EpChoixRDV = epSigne3
};
epSigne3.RdvEntretien = rdv3;
epContext.Ep.Add(epSigne3);
epSigne4 = new Ep()
{
DateDisponibilite = new DateTime(2017, 1, 20),
@ -275,6 +585,17 @@ namespace EPAServeur.Context
IdCollaborateur = new Guid("a0f40e2a-cc03-4032-a627-5389e1281c64"),
Obligatoire = false,
};
demandeEPI3 = new DemandeEPI()
{
IdReferent = new Guid("eb8b0f33-f529-4985-861e-1207f3312bb5"),
IdCollaborateur = new Guid("a0f40e2a-cc03-4032-a627-5389e1281c64"),
DateDemande = new DateTime(),
EtatDemande = EtatDemande.Validee,
DateReponse = new DateTime(),
Ep = epSigne4
};
epSigne4.DemandeEPI = demandeEPI3;
epContext.Ep.Add(epSigne4);
epSigne5 = new Ep()
@ -303,6 +624,7 @@ namespace EPAServeur.Context
IdCollaborateur = new Guid("a0f40e2a-cc03-4032-a627-5389e1281c64"),
Obligatoire = false,
};
epContext.Ep.Add(epSigne6);
epSigne7 = new Ep()
@ -317,6 +639,14 @@ namespace EPAServeur.Context
IdCollaborateur = new Guid("13fbe621-1bc9-4f04-afde-b54ca076e239"),
Obligatoire = false,
};
ca3 = new CommentaireAssistant()
{
Commentaire = "Commentaire assistant",
IdAssistant = new Guid("e6255f16-bcaf-48ac-b00b-97de83677ad8"),
Ep = epSigne7
};
epSigne7.CommentairesAssistant = new List<CommentaireAssistant>();
epSigne7.CommentairesAssistant.Add(ca3);
epContext.Ep.Add(epSigne7);
epSigne8 = new Ep()
@ -2005,5 +2335,6 @@ namespace EPAServeur.Context
context.SaveChanges();
}
}
}

@ -107,6 +107,7 @@ namespace EPAServeur.Context
{
entity.HasKey(e => e.IdRdvEntretien);
entity.Property(e => e.IdRdvEntretien).ValueGeneratedOnAdd();
entity.HasOne(e => e.TypeEntretien).WithMany(t => t.RdvEntretiens);
});
modelBuilder.Entity<ReferentEP>(entity =>
@ -116,7 +117,7 @@ namespace EPAServeur.Context
modelBuilder.Entity<ChoixTypeEntretien>(entity =>
{
entity.HasKey(e => e.Ordre);
entity.HasKey(e => e.IdChoixTypeEntretien);
});
@ -141,6 +142,7 @@ namespace EPAServeur.Context
{
entity.HasKey(e => e.IdTypeEntretien);
entity.HasIndex(e => e.Libelle).IsUnique();
entity.HasMany<ChoixTypeEntretien>(e => e.ChoixTypeEntretien).WithOne(c => c.TypeEntretien);
});
modelBuilder.Entity<CommentaireAssistant>(entity =>

@ -3,7 +3,7 @@
*
* API qui sra utilisée afin de faire communiquer le client et le serveur ainsi que le serveur et la boîte noire.
*
* OpenAPI spec version: 1.3.6
* OpenAPI spec version: 1.3.7
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
@ -30,22 +30,29 @@ namespace IO.Swagger.DTO
/// Id du commentaire assistant
/// </summary>
/// <value>Id du commentaire assistant</value>
[DataMember(Name="id")]
[DataMember(Name = "id")]
public long? Id { get; set; }
/// <summary>
/// Id de l&#x27;assistant qui a écrit le commentaire
/// </summary>
/// <value>Id de l&#x27;assistant qui a écrit le commentaire</value>
[DataMember(Name="idAssistante")]
public Guid? IdAssistante { get; set; }
[Required]
[DataMember(Name = "idAssistant")]
public Guid? IdAssistant { get; set; }
/// <summary>
/// Gets or Sets Assistant
/// </summary>
[DataMember(Name = "assistant")]
public string Assistant { get; set; }
/// <summary>
/// Le commentaire de l’assistant
/// </summary>
/// <value>Le commentaire de l’assistant</value>
[Required]
[DataMember(Name="commentaire")]
[DataMember(Name = "commentaire")]
public string Commentaire { get; set; }
/// <summary>
@ -57,7 +64,8 @@ namespace IO.Swagger.DTO
var sb = new StringBuilder();
sb.Append("class CommentaireAssistantDTO {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" IdAssistante: ").Append(IdAssistante).Append("\n");
sb.Append(" IdAssistant: ").Append(IdAssistant).Append("\n");
sb.Append(" Assistant: ").Append(Assistant).Append("\n");
sb.Append(" Commentaire: ").Append(Commentaire).Append("\n");
sb.Append("}\n");
return sb.ToString();
@ -101,9 +109,14 @@ namespace IO.Swagger.DTO
Id.Equals(other.Id)
) &&
(
IdAssistante == other.IdAssistante ||
IdAssistante != null &&
IdAssistante.Equals(other.IdAssistante)
IdAssistant == other.IdAssistant ||
IdAssistant != null &&
IdAssistant.Equals(other.IdAssistant)
) &&
(
Assistant == other.Assistant ||
Assistant != null &&
Assistant.Equals(other.Assistant)
) &&
(
Commentaire == other.Commentaire ||
@ -124,8 +137,10 @@ namespace IO.Swagger.DTO
// Suitable nullity checks etc, of course :)
if (Id != null)
hashCode = hashCode * 59 + Id.GetHashCode();
if (IdAssistante != null)
hashCode = hashCode * 59 + IdAssistante.GetHashCode();
if (IdAssistant != null)
hashCode = hashCode * 59 + IdAssistant.GetHashCode();
if (Assistant != null)
hashCode = hashCode * 59 + Assistant.GetHashCode();
if (Commentaire != null)
hashCode = hashCode * 59 + Commentaire.GetHashCode();
return hashCode;
@ -133,7 +148,7 @@ namespace IO.Swagger.DTO
}
#region Operators
#pragma warning disable 1591
#pragma warning disable 1591
public static bool operator ==(CommentaireAssistantDTO left, CommentaireAssistantDTO right)
{
@ -145,7 +160,7 @@ namespace IO.Swagger.DTO
return !Equals(left, right);
}
#pragma warning restore 1591
#pragma warning restore 1591
#endregion Operators
}
}

@ -3,7 +3,7 @@
*
* API qui sra utilisée afin de faire communiquer le client et le serveur ainsi que le serveur et la boîte noire.
*
* OpenAPI spec version: 1.3.6
* OpenAPI spec version: 1.3.7
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
@ -32,14 +32,14 @@ namespace IO.Swagger.DTO
/// </summary>
/// <value>Id de l’EP</value>
[Required]
[DataMember(Name="id")]
[DataMember(Name = "id")]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Type
/// </summary>
[Required]
[DataMember(Name="type")]
[DataMember(Name = "type")]
public TypeEp Type { get; set; }
/// <summary>
@ -47,7 +47,7 @@ namespace IO.Swagger.DTO
/// </summary>
/// <value>Date à partir de laquelle l&#x27;EP peut être saisi</value>
[Required]
[DataMember(Name="dateDisponibilite")]
[DataMember(Name = "dateDisponibilite")]
public DateTime? DateDisponibilite { get; set; }
/// <summary>
@ -55,35 +55,35 @@ namespace IO.Swagger.DTO
/// </summary>
/// <value>Date à laquelle l&#x27;EP est prévu, la date par défaut est celle de l&#x27;anniversaire du collaborateur (+6 mois pour EPS)</value>
[Required]
[DataMember(Name="datePrevisionnelle")]
[DataMember(Name = "datePrevisionnelle")]
public DateTime? DatePrevisionnelle { get; set; }
/// <summary>
/// Date à laquelle le collaborateur a signé l&#x27;EP
/// </summary>
/// <value>Date à laquelle le collaborateur a signé l&#x27;EP</value>
[DataMember(Name="dateSignatureCollaborateur")]
[DataMember(Name = "dateSignatureCollaborateur")]
public DateTime? DateSignatureCollaborateur { get; set; }
/// <summary>
/// Date à laquelle le référent a signé l&#x27;EP
/// </summary>
/// <value>Date à laquelle le référent a signé l&#x27;EP</value>
[DataMember(Name="dateSignatureReferent")]
[DataMember(Name = "dateSignatureReferent")]
public DateTime? DateSignatureReferent { get; set; }
/// <summary>
/// Date à laquelle l’EP a été saisi par le collaborateur
/// </summary>
/// <value>Date à laquelle l’EP a été saisi par le collaborateur</value>
[DataMember(Name="dateSaisie")]
[DataMember(Name = "dateSaisie")]
public DateTime? DateSaisie { get; set; }
/// <summary>
/// Gets or Sets Statut
/// </summary>
[Required]
[DataMember(Name="statut")]
[DataMember(Name = "statut")]
public StatutEp Statut { get; set; }
/// <summary>
@ -91,107 +91,107 @@ namespace IO.Swagger.DTO
/// </summary>
/// <value>Nom du CV Apside du collaborateur</value>
[Required]
[DataMember(Name="cv")]
[DataMember(Name = "cv")]
public string Cv { get; set; }
/// <summary>
/// Gets or Sets PropositionsEntretien
/// </summary>
[DataMember(Name="propositionsEntretien")]
[DataMember(Name = "propositionsEntretien")]
public List<RDVEntretienDTO> PropositionsEntretien { get; set; }
/// <summary>
/// Gets or Sets RdvEntretien
/// </summary>
[DataMember(Name="rdvEntretien")]
[DataMember(Name = "rdvEntretien")]
public RDVEntretienDTO RdvEntretien { get; set; }
/// <summary>
/// Gets or Sets ChoixTypeEntretien
/// </summary>
[DataMember(Name="choixTypeEntretien")]
public TypeEntretienDTO ChoixTypeEntretien { get; set; }
[DataMember(Name = "choixTypeEntretien")]
public List<TypeEntretienDTO> ChoixTypeEntretien { get; set; }
/// <summary>
/// Indique si oui ou non l&#x27;EP doit obligatoirement être effectué
/// </summary>
/// <value>Indique si oui ou non l&#x27;EP doit obligatoirement être effectué</value>
[Required]
[DataMember(Name="obligatoire")]
[DataMember(Name = "obligatoire")]
public bool? Obligatoire { get; set; }
/// <summary>
/// Gets or Sets Objectifs
/// </summary>
[Required]
[DataMember(Name="objectifs")]
[DataMember(Name = "objectifs")]
public List<ObjectifDTO> Objectifs { get; set; }
/// <summary>
/// Gets or Sets ObjectifsPrecedent
/// </summary>
[DataMember(Name="objectifsPrecedent")]
[DataMember(Name = "objectifsPrecedent")]
public List<ObjectifPrecedentDTO> ObjectifsPrecedent { get; set; }
/// <summary>
/// Gets or Sets Collaborateur
/// </summary>
[DataMember(Name="collaborateur")]
[DataMember(Name = "collaborateur")]
public CollaborateurDTO Collaborateur { get; set; }
/// <summary>
/// Gets or Sets Referent
/// </summary>
[DataMember(Name="referent")]
[DataMember(Name = "referent")]
public CollaborateurDTO Referent { get; set; }
/// <summary>
/// Gets or Sets DemandesFormation
/// </summary>
[DataMember(Name="demandesFormation")]
[DataMember(Name = "demandesFormation")]
public List<DemandeFormationDTO> DemandesFormation { get; set; }
/// <summary>
/// Gets or Sets Participants
/// </summary>
[DataMember(Name="participants")]
[DataMember(Name = "participants")]
public List<ParticipationEPDTO> Participants { get; set; }
/// <summary>
/// Gets or Sets Engagements
/// </summary>
[DataMember(Name="engagements")]
[DataMember(Name = "engagements")]
public List<EngagementDTO> Engagements { get; set; }
/// <summary>
/// Gets or Sets AugmentationSalaire
/// </summary>
[DataMember(Name="augmentationSalaire")]
[DataMember(Name = "augmentationSalaire")]
public AugmentationSalaireDTO AugmentationSalaire { get; set; }
/// <summary>
/// Gets or Sets DemandesDelegation
/// </summary>
[DataMember(Name="demandesDelegation")]
public List<DemandeDelegationDTO> DemandesDelegation { get; set; }
[DataMember(Name = "demandesDelegation")]
public DemandeDelegationDTO DemandesDelegation { get; set; }
/// <summary>
/// Gets or Sets DemandeEPI
/// </summary>
[DataMember(Name="demandeEPI")]
[DataMember(Name = "demandeEPI")]
public DemandeEPIDTO DemandeEPI { get; set; }
/// <summary>
/// Gets or Sets Documents
/// </summary>
[Required]
[DataMember(Name="documents")]
[DataMember(Name = "documents")]
public List<DocumentDTO> Documents { get; set; }
/// <summary>
/// Gets or Sets CommentairesAssistant
/// </summary>
[DataMember(Name="commentairesAssistant")]
[DataMember(Name = "commentairesAssistant")]
public List<CommentaireAssistantDTO> CommentairesAssistant { get; set; }
/// <summary>
@ -321,7 +321,7 @@ namespace IO.Swagger.DTO
(
ChoixTypeEntretien == other.ChoixTypeEntretien ||
ChoixTypeEntretien != null &&
ChoixTypeEntretien.Equals(other.ChoixTypeEntretien)
ChoixTypeEntretien.SequenceEqual(other.ChoixTypeEntretien)
) &&
(
Obligatoire == other.Obligatoire ||
@ -371,7 +371,7 @@ namespace IO.Swagger.DTO
(
DemandesDelegation == other.DemandesDelegation ||
DemandesDelegation != null &&
DemandesDelegation.SequenceEqual(other.DemandesDelegation)
DemandesDelegation.Equals(other.DemandesDelegation)
) &&
(
DemandeEPI == other.DemandeEPI ||
@ -455,7 +455,7 @@ namespace IO.Swagger.DTO
}
#region Operators
#pragma warning disable 1591
#pragma warning disable 1591
public static bool operator ==(EpDTO left, EpDTO right)
{
@ -467,7 +467,7 @@ namespace IO.Swagger.DTO
return !Equals(left, right);
}
#pragma warning restore 1591
#pragma warning restore 1591
#endregion Operators
}
}

@ -32,7 +32,7 @@ namespace IO.Swagger.DTO
/// <value>Id du type de l&#x27;entretien</value>
[Required]
[DataMember(Name="id")]
public int? Id { get; set; }
public long? Id { get; set; }
/// <summary>
/// Texte du type de l&#x27;entretien

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading.Tasks;
namespace EPAServeur.Exceptions
{
/// <summary>
/// Exceptin pour gérer les EP non trouvé
/// </summary>
public class EpNotFoundException : Exception
{
public EpNotFoundException()
{
}
public EpNotFoundException(string message) : base(message)
{
}
public EpNotFoundException(string message, Exception innerException) : base(message, innerException)
{
}
protected EpNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}

@ -26,7 +26,7 @@ namespace EPAServeur.IServices
#region Engagement
// Engagement
EngagementDTO GetEngagementDTO(Engagement engagement, IEnumerable<CollaborateurDTO> collaborateurDTOs);
EngagementDTO GetEngagementDTO(Engagement engagement, IEnumerable<CollaborateurDTO> collaborateurDTOs, bool recupEpInformation = true);
Engagement SetReponseEngagement(Engagement engagement, EngagementDTO engagementDTO);
#endregion
@ -72,16 +72,19 @@ namespace EPAServeur.IServices
// Récupération DetailsEP
EpDTO EpToEpDetails(Ep ep, IEnumerable<CollaborateurDTO> collaborateurDTOs);
List<EngagementDTO> GetEngagementDTOs(List<Engagement> engagements);
List<ParticipationEPDTO> GetParticipantsDTO(List<ParticipationEP> participants, IEnumerable<CollaborateurDTO> collaborateurDTOs);
List<CommentaireAssistantDTO> GetCommentaireAssistant(List<CommentaireAssistant> commentaireAssistant, IEnumerable<CollaborateurDTO> collaborateurDTOs);
DemandeDelegationDTO GetDemandeDelegationDTO(DemandeDelegation demandeDelegation, IEnumerable<CollaborateurDTO> collaborateurDTOs);
DemandeEPIDTO GetDemandeEPIDTO(DemandeEPI demande, IEnumerable<CollaborateurDTO> collaborateurDTOs);
AugmentationSalaireDTO GetAugmentationSalaireDTO(AugmentationSalaire augmentation);
DemandeDelegationDTO GetDemandeDelegationDTO(DemandeDelegation demandeDelegation, IEnumerable<CollaborateurDTO> collaborateurDTOs);
RDVEntretienDTO GetRDVEntretienDTO(RdvEntretien rdvEntretien);
TypeEntretienDTO GetEntretienDTO(ChoixTypeEntretien choixTypeEntretien);
DemandeFormationDTO GetDemandeFormationDTOEP(DemandeFormation demandeFormation);
TypeEntretienDTO GetTypeEntretienDTO(TypeEntretien typeEntretien);
List<RDVEntretienDTO> GetRDVEntretienDTOs(List<RdvEntretien> rdvEntretiens);
List<TypeEntretienDTO> GetTypeEntretienDTOs(List<ChoixTypeEntretien> choixTypeEntretiens);
DocumentDTO GetDocumentDTO(Document document);
ObjectifDTO GetObjectifDTO(Objectif objectif);
ObjectifPrecedentDTO GetObjectifPrecedentDTO(ObjectifPrecedent objectifPrecedent);
CommentaireAssistant GetCommentaireAssistant(CommentaireAssistant commentaireAssistant);
List<ObjectifDTO> GetObjectifDTOs(List<Objectif> objectifs);
List<ObjectifPrecedentDTO> GetObjectifPrecedentDTO(List<ObjectifPrecedent> objectifsPrecedents);

@ -10,6 +10,10 @@ namespace EPAServeur.Models.EP
/// </summary>
public class ChoixTypeEntretien
{
/// <summary>
/// Id
/// </summary>
public long IdChoixTypeEntretien { get; internal set; }
/// <summary>
/// Numéro d’ordre de préférence
/// </summary>

@ -18,7 +18,7 @@ namespace EPAServeur.Models.EP
/// <summary>
/// Id du collaborateur participant à l’EP
/// </summary>
public string IdParticipant { get; set; }
public Guid IdParticipant { get; set; }
/// <summary>
/// Indique si la participation est juste une participation d’un EP en cours ou des prochains EP en plus

@ -1,5 +1,9 @@
using EPAServeur.IServices;
using EPAServeur.Context;
using EPAServeur.Exceptions;
using EPAServeur.IServices;
using EPAServeur.Models.EP;
using IO.Swagger.DTO;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
@ -9,10 +13,55 @@ namespace EPAServeur.Services
{
public class EpDetailsService : IEpDetailsService
{
private EpContext context;
private ITransformDTO transformDTO;
private ICollaborateurService collaborateurService;
public Task<EpDTO> GetEp(long id)
public EpDetailsService(EpContext context, ITransformDTO transformDTO, ICollaborateurService collaborateurService)
{
throw new NotImplementedException();
this.context = context;
this.transformDTO = transformDTO;
this.collaborateurService = collaborateurService;
}
public async Task<EpDTO> GetEp(long id)
{
Ep ep = await context.Ep
.Include(ep => ep.Engagements)
.Include(ep => ep.Participants)
.Include(ep => ep.CommentairesAssistant)
.Include(ep => ep.DemandeDelegation)
.Include(ep => ep.RdvEntretien).ThenInclude(rdv => rdv.TypeEntretien)
.Include(ep => ep.PropositionsRDV).ThenInclude(rdv => rdv.TypeEntretien)
.Include(ep => ep.ChoixTypeEntretien).ThenInclude( c => c.TypeEntretien)
.Include(ep => ep.Objectifs)
.Include(ep => ep.ObjectifsPrecedents)
.Include(ep => ep.DemandeEPI)
.FirstOrDefaultAsync(ep => ep.IdEP.Equals(id));
if (ep == null)
throw new EpNotFoundException();
//ajouter tous les guids liés à l'EP et aux attributs de l'EP
List<Guid?> guids = new List<Guid?>
{
ep.IdCollaborateur
};
if (ep.IdReferent.HasValue)
guids.Add(ep.IdCollaborateur);
if (ep.Participants != null && ep.Participants.Any())
guids.AddRange(ep.Participants.SelectMany(p => new[] { (Guid?)p.IdParticipant }));
if (ep.CommentairesAssistant != null && ep.CommentairesAssistant.Any())
guids.AddRange(ep.CommentairesAssistant.SelectMany(p => new[] { (Guid?)p.IdAssistant }));
if (ep.DemandeDelegation != null)
guids.Add(ep.DemandeDelegation.IdReferent);
if (ep.DemandeEPI != null && ep.DemandeEPI.IdReferent != null)
guids.Add(ep.DemandeEPI.IdReferent);
IEnumerable<CollaborateurDTO> collaborateurDTOs = await collaborateurService.GetCollaborateurDTOsAsync(guids);
EpDTO epDTO = transformDTO.EpToEpDetails(ep, collaborateurDTOs);
return epDTO;
}
public void RappelSignature(long idEp)

@ -47,7 +47,31 @@ namespace EPAServeur.Services
/// <returns>L'EP transformé en DTO</returns>
public EpDTO EpToEpDetails(Ep ep, IEnumerable<CollaborateurDTO> collaborateurDTOs)
{
throw new NotImplementedException();
return new EpDTO()
{
Id = ep.IdEP,
Collaborateur = collaborateurDTOs.FirstOrDefault(c => c.Id.Equals(ep.IdCollaborateur)),
Referent = collaborateurDTOs.FirstOrDefault(c => c.Id.Equals(ep.IdCollaborateur)),
DateDisponibilite = ep.DateDisponibilite,
DatePrevisionnelle = ep.DatePrevisionnelle,
DateSaisie = ep.DateSaisie,
DateSignatureCollaborateur = ep.DateSignatureCollaborateur,
DateSignatureReferent = ep.DateSignatureReferent,
Obligatoire = ep.Obligatoire,
Statut = ep.Statut,
Type = ep.TypeEP,
Cv = ep.CV,
Engagements = GetEngagementDTOs(ep.Engagements),
Participants = GetParticipantsDTO(ep.Participants, collaborateurDTOs),
CommentairesAssistant = GetCommentaireAssistant(ep.CommentairesAssistant, collaborateurDTOs),
DemandesDelegation = GetDemandeDelegationDTO(ep.DemandeDelegation, collaborateurDTOs),
RdvEntretien = GetRDVEntretienDTO(ep.RdvEntretien),
PropositionsEntretien = GetRDVEntretienDTOs(ep.PropositionsRDV),
ChoixTypeEntretien = GetTypeEntretienDTOs(ep.ChoixTypeEntretien),
Objectifs = GetObjectifDTOs(ep.Objectifs),
ObjectifsPrecedent = GetObjectifPrecedentDTO(ep.ObjectifsPrecedents),
DemandeEPI = GetDemandeEPIDTO(ep.DemandeEPI, collaborateurDTOs)
};
}
/// <summary>
@ -189,11 +213,28 @@ namespace EPAServeur.Services
/// <summary>
/// Transformer un commentaire assistante en objet DTO
/// </summary>
/// <param name="commentaireAssistant">Le commentaire a transformé en DTO</param>
/// <param name="commentaireAssistant">Les commentaire a transformé en DTO</param>
/// <returns>Le commentaire assistant transformé en DTO</returns>
public CommentaireAssistant GetCommentaireAssistant(CommentaireAssistant commentaireAssistant)
public List<CommentaireAssistantDTO> GetCommentaireAssistant(List<CommentaireAssistant> commentairesAssistant, IEnumerable<CollaborateurDTO> collaborateurDTOs)
{
throw new NotImplementedException();
if (commentairesAssistant == null || !commentairesAssistant.Any())
return null;
List<CommentaireAssistantDTO> commentaireAssistantDTO = new List<CommentaireAssistantDTO>();
foreach(CommentaireAssistant ca in commentairesAssistant)
{
CollaborateurDTO c = collaborateurDTOs.FirstOrDefault(collaborateur => collaborateur.Id.Equals(ca.IdAssistant));
if(c != null)
{
commentaireAssistantDTO.Add(new CommentaireAssistantDTO()
{
Commentaire = ca.Commentaire,
Id = ca.IdCommentaireAssistant,
IdAssistant = ca.IdAssistant,
Assistant = c.Nom + " " + c.Prenom
});
}
}
return commentaireAssistantDTO.Any() ? commentaireAssistantDTO : null;
}
@ -227,7 +268,19 @@ namespace EPAServeur.Services
/// <returns>La demande de délégation transformé en DTO</returns>
public DemandeDelegationDTO GetDemandeDelegationDTO(DemandeDelegation demandeDelegation, IEnumerable<CollaborateurDTO> collaborateurDTOs)
{
throw new NotImplementedException();
if (demandeDelegation == null)
return null;
DemandeDelegationDTO demandeDelegationDTO = new DemandeDelegationDTO()
{
DateDemande = demandeDelegation.DateDemande,
DateReponse = demandeDelegation.DateReponse,
EtatDemande = demandeDelegation.EtatDemande,
Id = demandeDelegation.IdDemandeDelegation,
RaisonDemande = demandeDelegation.RaisonDemande,
RaisonRefus = demandeDelegation.RaisonRefus,
Referent = collaborateurDTOs.FirstOrDefault(c => c.Id.Equals(demandeDelegation.IdReferent))
};
return demandeDelegationDTO.Referent != null ? demandeDelegationDTO : null;
}
/// <summary>
@ -238,7 +291,18 @@ namespace EPAServeur.Services
/// <returns></returns>
public DemandeEPIDTO GetDemandeEPIDTO(DemandeEPI demande, IEnumerable<CollaborateurDTO> collaborateurDTOs)
{
throw new NotImplementedException();
if (demande == null)
return null;
return new DemandeEPIDTO()
{
Collaborateur = collaborateurDTOs.FirstOrDefault(c => c.Id.Equals(demande.IdCollaborateur)),
Id = demande.IdDemandeEPI,
DateDemande = demande.DateDemande,
DateReponse = demande.DateReponse,
EtatDemande = demande.EtatDemande,
RaisonRefus = demande.RaisonRefus,
Referent = collaborateurDTOs.FirstOrDefault(c => c.Id.Equals(demande.IdReferent))
};
}
@ -260,9 +324,9 @@ namespace EPAServeur.Services
/// <param name="engagement"></param>
/// <param name="collaborateurDTOs"></param>
/// <returns></returns>
public EngagementDTO GetEngagementDTO(Engagement engagement, IEnumerable<CollaborateurDTO> collaborateurDTOs)
public EngagementDTO GetEngagementDTO(Engagement engagement, IEnumerable<CollaborateurDTO> collaborateurDTOs, bool recupEpInformation = true)
{
if (engagement == null || collaborateurDTOs == null || !collaborateurDTOs.Any())
if ( engagement == null || recupEpInformation && ( collaborateurDTOs == null || !collaborateurDTOs.Any()))
return null;
EngagementDTO engagementDTO = new EngagementDTO()
@ -274,15 +338,26 @@ namespace EPAServeur.Services
Modalite = engagement.Modalite,
RaisonNonRealisable = engagement.RaisonNonRealisable,
EtatEngagement = engagement.EtatEngagement,
Ep = GetEpInformationDTO(engagement.Ep, collaborateurDTOs)
};
if (recupEpInformation)
engagementDTO.Ep = GetEpInformationDTO(engagement.Ep, collaborateurDTOs);
return engagementDTO;
}
public TypeEntretienDTO GetEntretienDTO(ChoixTypeEntretien choixTypeEntretien)
public List<EngagementDTO> GetEngagementDTOs(List<Engagement> engagements)
{
throw new NotImplementedException();
if (engagements == null || engagements.Count == 0)
return null;
return engagements.Select(engagment => GetEngagementDTO(engagment, null, false)).ToList();
}
public TypeEntretienDTO GetTypeEntretienDTO(TypeEntretien typeEntretien)
{
return new TypeEntretienDTO()
{
Id = typeEntretien.IdTypeEntretien,
Libelle = typeEntretien.Libelle
};
}
/// <summary>
@ -469,15 +544,6 @@ namespace EPAServeur.Services
return modeFormationDTO;
}
public ObjectifDTO GetObjectifDTO(Objectif objectif)
{
throw new NotImplementedException();
}
public ObjectifPrecedentDTO GetObjectifPrecedentDTO(ObjectifPrecedent objectifPrecedent)
{
throw new NotImplementedException();
}
/// <summary>
/// Transformer un objet OrigineFormationDTO en objet OrigineFormation.
@ -518,6 +584,28 @@ namespace EPAServeur.Services
return origineFormationDTO;
}
public List<ParticipationEPDTO> GetParticipantsDTO(List<ParticipationEP> participants, IEnumerable<CollaborateurDTO> collaborateurDTOs)
{
if (participants == null || !participants.Any())
return null;
List<ParticipationEPDTO> participantsDTO = new List<ParticipationEPDTO>();
foreach(ParticipationEP p in participants)
{
CollaborateurDTO c = collaborateurDTOs.FirstOrDefault( c => c.Id.Equals(p.IdParticipant));
if(c != null)
{
participantsDTO.Add(new ParticipationEPDTO()
{
Id = p.IdParticipationEP,
EstPermanente = p.EstPermanente,
IdParticipant = c.Id,
Participant = c.Nom + " " + c.Prenom
});
}
}
return participantsDTO.Any() ? participantsDTO : null;
}
/// <summary>
/// Transformer un objet ParticipationFormation en objet ParticipationFormationDTO.
/// La liste de collaborateurs est utilisé pour alimenter la propriété Collaborateur et la propriété Ep de l'objet FormationDTO.
@ -568,7 +656,21 @@ namespace EPAServeur.Services
public RDVEntretienDTO GetRDVEntretienDTO(RdvEntretien rdvEntretien)
{
throw new NotImplementedException();
if (rdvEntretien == null)
return null;
return new RDVEntretienDTO()
{
Id = rdvEntretien.IdRdvEntretien,
DateEntretien = rdvEntretien.DateEntretien,
TypeEntretien = GetTypeEntretienDTO(rdvEntretien.TypeEntretien)
};
}
public List<RDVEntretienDTO> GetRDVEntretienDTOs(List<RdvEntretien> rdvEntretiens)
{
if (rdvEntretiens == null || !rdvEntretiens.Any())
return null;
return rdvEntretiens.Select(rdv => GetRDVEntretienDTO(rdv)).ToList();
}
@ -651,6 +753,14 @@ namespace EPAServeur.Services
};
return statutFormationDTO;
}
public List<TypeEntretienDTO> GetTypeEntretienDTOs(List<ChoixTypeEntretien> choixTypeEntretiens)
{
if (choixTypeEntretiens == null || !choixTypeEntretiens.Any())
return null;
return choixTypeEntretiens.OrderBy(c => c.Ordre).Select(c => GetTypeEntretienDTO(c.TypeEntretien)).ToList();
}
/// <summary>
@ -795,5 +905,29 @@ namespace EPAServeur.Services
return engagement;
}
public List<ObjectifDTO> GetObjectifDTOs(List<Objectif> objectifs)
{
if (objectifs == null || !objectifs.Any())
return null;
return objectifs.Select(o => new ObjectifDTO()
{
Id = o.IdObjectif,
Libelle = o.Libelle
}).ToList();
}
public List<ObjectifPrecedentDTO> GetObjectifPrecedentDTO(List<ObjectifPrecedent> objectifsPrecedents)
{
if (objectifsPrecedents == null || !objectifsPrecedents.Any())
return null;
return objectifsPrecedents.Select(o => new ObjectifPrecedentDTO()
{
Id = o.IdObjectif,
Libelle = o.Libelle,
StatutObjectif = o.StatutObjectif,
Commentaire = o.Commentaire
}).ToList();
}
}
}

Loading…
Cancel
Save