|
|
@ -1,6 +1,8 @@ |
|
|
|
using EPAServeur.Context; |
|
|
|
using EPAServeur.Context; |
|
|
|
using EPAServeur.IServices; |
|
|
|
using EPAServeur.IServices; |
|
|
|
|
|
|
|
using EPAServeur.Models.EP; |
|
|
|
using IO.Swagger.DTO; |
|
|
|
using IO.Swagger.DTO; |
|
|
|
|
|
|
|
using IO.Swagger.Enum; |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq; |
|
|
@ -10,43 +12,99 @@ namespace EPAServeur.Services |
|
|
|
{ |
|
|
|
{ |
|
|
|
public class EpInformationService : IEpInformationService |
|
|
|
public class EpInformationService : IEpInformationService |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#region Variables |
|
|
|
private EpContext context; |
|
|
|
private EpContext context; |
|
|
|
private ICollaborateurService collaborateurService; |
|
|
|
private ICollaborateurService collaborateurService; |
|
|
|
|
|
|
|
private int? minParPage = 5; |
|
|
|
|
|
|
|
private int? maxParPage = 100; |
|
|
|
|
|
|
|
private int? defaultParPage = 15; |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region constructeur |
|
|
|
public EpInformationService(EpContext context, ICollaborateurService collaborateurService) |
|
|
|
public EpInformationService(EpContext context, ICollaborateurService collaborateurService) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.context = context; |
|
|
|
this.context = context; |
|
|
|
this.collaborateurService = collaborateurService; |
|
|
|
this.collaborateurService = collaborateurService; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<EpInformationDTO>> GetEPEnCours(List<long?> idBUs, bool asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
|
|
|
|
|
|
|
|
#region Services async |
|
|
|
|
|
|
|
public async Task<IEnumerable<EpInformationDTO>> GetEPEnCours(List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
IEnumerable<Ep> eps = context.Ep.Where(ep => idBUs.Contains(ep.IdBu)).Where(ep => estEpEnCours(ep.Statut)); |
|
|
|
|
|
|
|
eps = TriDate(eps, dateDebut, dateFin); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Guid?> guids = eps.SelectMany(ep => new Guid?[] { ep.IdReferent, ep.IdCollaborateur }).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerable<CollaborateurDTO> collaborateurDTOs = await collaborateurService.GetCollaborateurDTOsAsync(guids); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerable<EpInformationDTO> epDTOs = eps.Select(ep => EpToEpDTO(ep, collaborateurDTOs)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
epDTOs = epDTOs.Where(e => TriTexte(e, texte)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
epDTOs = TriColonne(epDTOs, tri); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (asc != null && asc.HasValue && !asc.Value) |
|
|
|
|
|
|
|
epDTOs = epDTOs.Reverse(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return SkipAndTake(epDTOs, numPage, parPage); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<EpInformationDTO>> GetEPEnCoursCollaborateurParticipant(Guid? idCollaborateur) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<int> GetEPEnCoursCount(List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
IEnumerable<Ep> eps = context.Ep.Where(ep => idBUs.Contains(ep.IdBu)).Where(ep => estEpEnCours(ep.Statut)); |
|
|
|
|
|
|
|
eps = TriDate(eps, dateDebut, dateFin); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Guid?> guids = eps.SelectMany(ep => new Guid?[] { ep.IdReferent, ep.IdCollaborateur }).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerable<CollaborateurDTO> collaborateurDTOs = await collaborateurService.GetCollaborateurDTOsAsync(guids); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerable<EpInformationDTO> epDTOs = eps.Select(ep => EpToEpDTO(ep, collaborateurDTOs)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
epDTOs = epDTOs.Where(e => TriTexte(e, texte)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return epDTOs.Count(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<int> GetEPEnCoursCount(List<long?> idBUs, bool asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
public async Task<IEnumerable<EpInformationDTO>> GetEPEnCoursCollaborateurParticipant(Guid? idCollaborateur) |
|
|
|
{ |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
throw new NotImplementedException(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<EpInformationDTO>> GetEPEnCoursReferent(Guid? idReferent, bool asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
public async Task<IEnumerable<EpInformationDTO>> GetEPEnCoursReferent(Guid? idReferent, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
throw new NotImplementedException(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<int> GetEPEnCoursReferentCount(Guid? idReferent, bool asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
public async Task<int> GetEPEnCoursReferentCount(Guid? idReferent, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
throw new NotImplementedException(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<EpInformationDTO>> GetEPSignes(List<long?> idBUs, bool asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
public async Task<IEnumerable<EpInformationDTO>> GetEPSignes(List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
IEnumerable<Ep> eps = context.Ep.Where(ep => idBUs.Contains(ep.IdBu)).Where(ep => ep.Statut == StatutEp.Signe); |
|
|
|
|
|
|
|
eps = TriDate(eps, dateDebut, dateFin); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Guid?> guids = eps.SelectMany(ep => new Guid?[] { ep.IdReferent, ep.IdCollaborateur }).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerable<CollaborateurDTO> collaborateurDTOs = await collaborateurService.GetCollaborateurDTOsAsync(guids); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerable<EpInformationDTO> epDTOs = eps.Select(ep => EpToEpDTO(ep, collaborateurDTOs)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
epDTOs = epDTOs.Where(e => TriTexte(e, texte)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
epDTOs = TriColonne(epDTOs, tri); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (asc != null && asc.HasValue && !asc.Value) |
|
|
|
|
|
|
|
epDTOs = epDTOs.Reverse(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return SkipAndTake(epDTOs, numPage, parPage); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<EpInformationDTO>> GetEPSignesCollaborateur(Guid? idCollaborateur) |
|
|
|
public async Task<IEnumerable<EpInformationDTO>> GetEPSignesCollaborateur(Guid? idCollaborateur) |
|
|
@ -54,17 +112,28 @@ namespace EPAServeur.Services |
|
|
|
throw new NotImplementedException(); |
|
|
|
throw new NotImplementedException(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<int> GetEPSignesCount(List<long?> idBUs, bool asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
public async Task<int> GetEPSignesCount(List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
IEnumerable<Ep> eps = context.Ep.Where(ep => idBUs.Contains(ep.IdBu)).Where(ep => ep.Statut == StatutEp.Signe); |
|
|
|
|
|
|
|
eps = TriDate(eps, dateDebut, dateFin); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Guid?> guids = eps.SelectMany(ep => new Guid?[] { ep.IdReferent, ep.IdCollaborateur }).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerable<CollaborateurDTO> collaborateurDTOs = await collaborateurService.GetCollaborateurDTOsAsync(guids); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerable<EpInformationDTO> epDTOs = eps.Select(ep => EpToEpDTO(ep, collaborateurDTOs)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
epDTOs = epDTOs.Where(e => TriTexte(e, texte)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return epDTOs.Count(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<EpInformationDTO>> GetEPSignesReferent(Guid? idReferent, bool asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
public async Task<IEnumerable<EpInformationDTO>> GetEPSignesReferent(Guid? idReferent, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
throw new NotImplementedException(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<int> GetEPSignesReferentCount(Guid? idReferent, bool asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
public async Task<int> GetEPSignesReferentCount(Guid? idReferent, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
throw new NotImplementedException(); |
|
|
|
} |
|
|
|
} |
|
|
@ -73,5 +142,82 @@ namespace EPAServeur.Services |
|
|
|
{ |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
throw new NotImplementedException(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region méthodes privées |
|
|
|
|
|
|
|
private IEnumerable<Ep> TriDate(IEnumerable<Ep> eps, DateTime? dateDebut, DateTime? dateFin) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (dateDebut.HasValue && dateDebut.Value != null) |
|
|
|
|
|
|
|
eps = eps.Where(ep => ep.DatePrevisionnelle >= dateDebut.Value); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dateFin.HasValue && dateFin.Value != null) |
|
|
|
|
|
|
|
eps = eps.Where(ep => ep.DatePrevisionnelle < dateFin.Value.AddDays(1)); |
|
|
|
|
|
|
|
return eps; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private EpInformationDTO EpToEpDTO(Ep ep, IEnumerable<CollaborateurDTO> collaborateurDTOs) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return new EpInformationDTO() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Id = ep.IdEP, |
|
|
|
|
|
|
|
Collaborateur = collaborateurDTOs.Where(c => c.Id.Equals(ep.IdCollaborateur)).FirstOrDefault(), |
|
|
|
|
|
|
|
DateDisponibilite = ep.DateDisponibilite, |
|
|
|
|
|
|
|
DatePrevisionnelle = ep.DatePrevisionnelle, |
|
|
|
|
|
|
|
Obligatoire = ep.Obligatoire, |
|
|
|
|
|
|
|
Referent = collaborateurDTOs.FirstOrDefault(c => c.Id.Equals(ep.IdReferent)), |
|
|
|
|
|
|
|
Statut = ep.Statut, |
|
|
|
|
|
|
|
Type = ep.TypeEP |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private IEnumerable<EpInformationDTO> TriColonne(IEnumerable<EpInformationDTO> epDTOs, string tri) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
switch (tri) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case "agence": |
|
|
|
|
|
|
|
epDTOs = epDTOs.OrderBy(e => e.Collaborateur.BusinessUnit.Nom); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case "collaborateur": |
|
|
|
|
|
|
|
epDTOs = epDTOs.OrderBy(e => e.Collaborateur.Nom + e.Collaborateur.Prenom); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case "referent": |
|
|
|
|
|
|
|
epDTOs = epDTOs.OrderBy(e => e.Referent.Nom + e.Referent.Prenom); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case "date": |
|
|
|
|
|
|
|
epDTOs = epDTOs.OrderBy(e => e.DatePrevisionnelle); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case "typeep": |
|
|
|
|
|
|
|
epDTOs = epDTOs.OrderBy(e => e.Type); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case "etatep": |
|
|
|
|
|
|
|
epDTOs = epDTOs.OrderBy(e => e.Statut); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return epDTOs; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private IEnumerable<EpInformationDTO> SkipAndTake(IEnumerable<EpInformationDTO> epDTOs, int? numPage, int? parPage) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(numPage == null ||!numPage.HasValue) |
|
|
|
|
|
|
|
numPage = 1; |
|
|
|
|
|
|
|
if (parPage == null || !parPage.HasValue || parPage < minParPage || parPage > maxParPage) |
|
|
|
|
|
|
|
parPage = defaultParPage; |
|
|
|
|
|
|
|
int skip = (numPage.Value - 1) * parPage.Value; |
|
|
|
|
|
|
|
return epDTOs.Skip(skip).Take(parPage.Value); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private bool estEpEnCours(StatutEp statut) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return statut != StatutEp.Annule && statut != StatutEp.Cree && statut != StatutEp.Rejete && statut != StatutEp.Signe; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private bool TriTexte(EpInformationDTO epDTOs, string texte) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return (epDTOs.Collaborateur.Nom + " " + epDTOs.Collaborateur.Prenom).Contains(texte) || (epDTOs.Collaborateur.Prenom + " " + epDTOs.Collaborateur.Nom).Contains(texte); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|