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.
Digitalisation_EPA_Serveur/EPAServeur/Services/DemandeFormationService.cs

600 lines
29 KiB

using EPAServeur.Context;
using EPAServeur.Exceptions;
using EPAServeur.IServices;
using EPAServeur.Models.EP;
using EPAServeur.Models.Formation;
using EPAServeur.Models.SaisieChamp;
using IO.Swagger.DTO;
using IO.Swagger.Enum;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EPAServeur.Services
{
public class DemandeFormationService : IDemandeFormationService
{
#region Variables
/// <summary>
/// Accès et gestion de la base de données
/// </summary>
private readonly EpContext epContext;
/// <summary>
/// Accès au service collaborateur
/// </summary>
private readonly ICollaborateurService collaborateurService;
/// <summary>
/// Accès au service permettant de transformer un modèle en dto
/// </summary>
private readonly ITransformDTO transformDTO;
/// <summary>
/// Nombre d'éléments min à afficher par page
/// </summary>
private readonly int minParPage = 5;
/// <summary>
/// Nom d'éléments max à affichar par page
/// </summary>
private readonly int maxParPage = 100;
/// <summary>
/// Nombre d'éléments à afficher par défaut par page
/// </summary>
private readonly int defaultParPage = 15;
/// <summary>
/// Numéro de page min à afficher par défaut
/// </summary>
private readonly int defaultNumPage = 1;
/// <summary>
/// Ordonnancement par défaut
/// </summary>
private readonly bool defaultAsc = true;
#endregion
#region Contructeurs
/// <summary>
/// Constructeur de la classe FormationService
/// </summary>
/// <param name="_epContext"></param>
public DemandeFormationService(EpContext _epContext, ICollaborateurService _collaborateurService, ITransformDTO _transformDTO)
{
epContext = _epContext;
collaborateurService = _collaborateurService;
transformDTO = _transformDTO;
}
#endregion
#region Méthodes Service
/// <summary>
/// Récupérer la liste des origines des demandes de formation.
/// </summary>
/// <returns></returns>
public async Task<IEnumerable<OrigineDemandeFormationDTO>> GetOriginesDemandeFormationAsync()
{
IEnumerable<OrigineDemande> origineDemandes;
IEnumerable<OrigineDemandeFormationDTO> origineDemandeDTOs;
origineDemandes = await epContext.OrigineDemandeFormation.ToListAsync();
origineDemandeDTOs = origineDemandes.Select(origineFormation => transformDTO.GetOrigineDemandeFormationDTO(origineFormation));
return origineDemandeDTOs;
}
/// <summary>
/// Récupérer la liste des demandes de formation.
/// </summary>
/// <param name="etatsDemande">Liste des états des demandes à afficher</param>
/// <param name="idBUs">liste des ids des BU auxquelles les données sont rattachées</param>
/// <param name="asc">Indique si les données sont récupérées dans l&#x27;ordre croissant ou non</param>
/// <param name="numPage">Numéro de la page du tableau à afficher</param>
/// <param name="parPage">Nombre d’élément maximum à afficher dans le tableau</param>
/// <param name="texte">Texte permettant de filtrer les données</param>
/// <param name="tri">Colonne du tableau sur lequel le tri devra être effectué</param>
/// <param name="dateDebut">Date à partir de laquelle les données son récupérées</param>
/// <param name="dateFin">Date jusqu&#x27;à laquelle les données sont récupérées</param>
/// <returns></returns>
public async Task<IEnumerable<DemandeFormationDTO>> GetDemandesFormationAsync(List<EtatDemande> etatsDemande, List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin)
{
IQueryable<DemandeFormation> query;
IEnumerable<DemandeFormation> demandeFormations;
IEnumerable<DemandeFormationDTO> demandeFormationDTOs;
IEnumerable<CollaborateurDTO> collaborateurDTOs;
query = epContext.DemandeFormation
.Include(demandeFormation => demandeFormation.Ep)
.Include(demandeFormation => demandeFormation.OrigineDemande)
.Include(demandeFormation => demandeFormation.ParticipationFormation)
.ThenInclude(participationFormation => participationFormation.Formation);
query = StatutEpFilter(query);
query = EtatsDemandeFilter(query, etatsDemande);
query = IdBUsFilter(query, idBUs);
query = DateFilter(query, dateDebut, dateFin);
query = SkipAndTake(query, parPage, numPage);
demandeFormations = await query.ToListAsync();
collaborateurDTOs = await collaborateurService.GetCollaborateurDTOsAsync(demandeFormations);
demandeFormationDTOs = demandeFormations.Select(demandeFormation => transformDTO.GetDemandeFormationDTO(demandeFormation, collaborateurDTOs));
demandeFormationDTOs = CollaborateurFilter(demandeFormationDTOs, texte);
demandeFormationDTOs = OrderByColumn(demandeFormationDTOs, asc, tri);
return demandeFormationDTOs;
}
/// <summary>
/// Récupérer le nombre total de demandes de formation.
/// </summary>
/// <param name="etatsDemande">Liste des états des demandes à afficher</param>
/// <param name="idBUs">liste des ids des BU auxquelles les données sont rattachées</param>
/// <param name="texte">Texte permettant de filtrer les données</param>
/// <param name="dateDebut">Date à partir de laquelle les données son récupérées</param>
/// <param name="dateFin">Date jusqu&#x27;à laquelle les données sont récupérées</param>
/// <returns></returns>
public async Task<long> GetDemandesFormationCountAsync(List<EtatDemande> etatsDemande, List<long?> idBUs, string texte, DateTime? dateDebut, DateTime? dateFin)
{
IQueryable<DemandeFormation> query;
IEnumerable<DemandeFormation> demandeFormations;
IEnumerable<DemandeFormationDTO> demandeFormationDTOs;
IEnumerable<CollaborateurDTO> collaborateurDTOs;
long count;
query = epContext.DemandeFormation
.Include(demandeFormation => demandeFormation.Ep)
.Include(demandeFormation => demandeFormation.ParticipationFormation)
.ThenInclude(participationFormation => participationFormation.Formation);
query = StatutEpFilter(query);
query = EtatsDemandeFilter(query, etatsDemande);
query = IdBUsFilter(query, idBUs);
query = DateFilter(query, dateDebut, dateFin);
demandeFormations = await query.ToListAsync();
collaborateurDTOs = await collaborateurService.GetCollaborateurDTOsAsync(demandeFormations);
demandeFormationDTOs = demandeFormations.Select(demandeFormation => transformDTO.GetDemandeFormationDTO(demandeFormation, collaborateurDTOs));
demandeFormationDTOs = CollaborateurFilter(demandeFormationDTOs, texte);
count = demandeFormationDTOs.Count();
return count;
}
/// <summary>
/// Créer une demande de formation pour un collaborateur.
/// </summary>
/// <param name="demandeFormationDTO"></param>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationInvalidException"></exception>
/// <returns></returns>
public async Task<DemandeFormationDTO> AddDemandeFormationAsync(DemandeFormationDTO demandeFormationDTO)
{
IsDemandeFormationValide(demandeFormationDTO);
if (demandeFormationDTO.EtatDemande != EtatDemande.EnAttente)
throw new DemandeFormationInvalidException("Impossible de créer une demande de formation qui n'est pas en attente.");
string collaborateur = string.Format("{0} {1}", demandeFormationDTO.Collaborateur.Nom, demandeFormationDTO.Collaborateur.Prenom);
DemandeFormation demandeFormation = transformDTO.SetDemandeFormationWithoutParticipationFormationAndEp(new DemandeFormation(), demandeFormationDTO);
IEnumerable<StatutEp> statutsEp = Enum.GetValues(typeof(StatutEp)).Cast<StatutEp>().Where(statut => statut == StatutEp.Cree || EstEpEnCours(statut));
Ep ep = await epContext.Ep.Include(ep => ep.DemandesFormation)
.Where(ep => ep.IdCollaborateur == demandeFormationDTO.Collaborateur.Id && statutsEp.Contains(ep.Statut))
.OrderBy(ep => ep.DateDisponibilite).FirstOrDefaultAsync();
if (ep == null)
throw new DemandeFormationInvalidException(string.Format("Il n'existe aucun EP en cours ou créé pour le collaborateur {0}.", collaborateur));
ep.DemandesFormation.Add(demandeFormation);
await epContext.SaveChangesAsync();
demandeFormationDTO.Id = demandeFormation.IdDemandeFormation;
return demandeFormationDTO;
}
/// <summary>
/// Répondre à une demande de formation.
/// </summary>
/// <param name="idDemandeFormation"></param>
/// <param name="demandeFormationDTO"></param>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationIncompatibleIdException"></exception>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationInvalidException"></exception>
/// <returns></returns>
public async Task<DemandeFormationDTO> UpdateDemandeFormationAsync(long idDemandeFormation, DemandeFormationDTO demandeFormationDTO)
{
IsDemandeFormationValide(demandeFormationDTO);
if (!demandeFormationDTO.Id.HasValue || demandeFormationDTO.Id.Value != idDemandeFormation)
throw new DemandeFormationIncompatibleIdException("La demande de formation ne correspond pas avec l'identifiant reçu.");
switch (demandeFormationDTO.EtatDemande)
{
case EtatDemande.EnAttente:
throw new DemandeFormationInvalidException("La demande ne peut pas être mise à jour si aucune réponse n'a été donnée.");
case EtatDemande.Validee:
demandeFormationDTO = await AccepterDemandeFormation(idDemandeFormation, demandeFormationDTO);
break;
case EtatDemande.Rejetee:
demandeFormationDTO = await RefuserDemandeFormation(idDemandeFormation, demandeFormationDTO);
break;
}
return demandeFormationDTO;
}
/// <summary>
/// Supprimer une demande de formation.
/// </summary>
/// <param name="idDemandeFormation"></param>
/// <returns></returns>
public async Task<bool> DeleteDemandeFormationAsync(long idDemandeFormation)
{
IEnumerable<StatutEp> statutsEp = Enum.GetValues(typeof(StatutEp)).Cast<StatutEp>().Where(statut => statut == StatutEp.Cree || EstEpEnCours(statut));
DemandeFormation demandeFormation = await epContext.DemandeFormation.Include(demandeFormation => demandeFormation.Ep)
.FirstOrDefaultAsync(demandeFormation => demandeFormation.IdDemandeFormation == idDemandeFormation);
if (demandeFormation == null)
throw new DemandeFormationNotFoundException("Aucune demande de formation n'a été trouvée.");
if (!statutsEp.Contains(demandeFormation.Ep.Statut))
throw new DemandeFormationInvalidException(string.Format("L'EP {1} qui est rattaché à la demande de formation {0} n'est ni créé ni en cours. Statut de l'EP {1}: {2}.", demandeFormation.IdDemandeFormation, demandeFormation.Ep.IdEP, demandeFormation.Ep.Statut));
epContext.Remove(demandeFormation);
await epContext.SaveChangesAsync();
return true;
}
#endregion
#region Méthodes Privée
/// <summary>
/// Accepter une demande de formation.
/// </summary>
/// <remarks>Créer une participation formation et associe cette dernière la demande de formation</remarks>
/// <param name="idDemandeFormation"></param>
/// <param name="demandeFormationDTO"></param>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationInvalidException"></exception>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationNotFoundException"></exception>
/// <returns></returns>
private async Task<DemandeFormationDTO> AccepterDemandeFormation(long idDemandeFormation, DemandeFormationDTO demandeFormationDTO)
{
// Vérifier que la demande de formation a bien une formation
if (demandeFormationDTO.Formation == null || !demandeFormationDTO.Formation.Id.HasValue)
throw new DemandeFormationInvalidException("Une formation est requise pour accepter une demande de formation.");
DemandeFormation demandeFormation = await epContext.DemandeFormation.Include(d => d.ParticipationFormation)
.Include(d => d.Ep)
.FirstOrDefaultAsync(d => d.IdDemandeFormation == idDemandeFormation);
if (demandeFormation == null)
throw new DemandeFormationNotFoundException("Aucune demande de formation n'a été trouvée.");
Guid idCollaborateur = demandeFormation.Ep.IdCollaborateur; // devra être utilisé pour notifier le collaborateur
DateTime dateNow = DateTime.Now;
Formation formation = transformDTO.GetFormation(demandeFormationDTO.Formation);
ParticipationFormation participationFormation = new ParticipationFormation { DateCreation = dateNow, Formation = formation };
demandeFormation.Etat = demandeFormationDTO.EtatDemande;
demandeFormation.DateDerniereReponse = dateNow;
demandeFormation.ParticipationFormation = participationFormation;
await epContext.SaveChangesAsync();
int nbParticipations = await epContext.ParticipationFormation.Include(p => p.DemandeFormation).Where(p => p.Formation.IdFormation == formation.IdFormation).CountAsync();
demandeFormationDTO.EtatDemande = demandeFormation.Etat;
demandeFormationDTO.DateDerniereReponse = demandeFormation.DateDerniereReponse;
demandeFormationDTO.Formation.NbParticipations = nbParticipations;
return demandeFormationDTO;
}
/// <summary>
/// Refuser une demande de formation.
/// </summary>
/// <remarks>Supprime la participation formation qui est liée à la demande de formation</remarks>
/// <param name="idDemandeFormation"></param>
/// <param name="demandeFormationDTO"></param>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationInvalidException"></exception>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationNotFoundException"></exception>
/// <returns></returns>
private async Task<DemandeFormationDTO> RefuserDemandeFormation(long idDemandeFormation, DemandeFormationDTO demandeFormationDTO)
{
// Vérifier que la demande de formation a bien un commentaire expliquant la raison pour laquelle la demande a été refusée
if (string.IsNullOrWhiteSpace(demandeFormationDTO.CommentaireRefus))
throw new DemandeFormationInvalidException("Un commentaire expliquant la raison pour laquelle la demande a été refusée est requis.");
DemandeFormation demandeFormation = await epContext.DemandeFormation.Include(d => d.ParticipationFormation)
.Include(d => d.Ep)
.FirstOrDefaultAsync(d => d.IdDemandeFormation == idDemandeFormation);
if (demandeFormation == null)
throw new DemandeFormationNotFoundException("Aucune demande de formation n'a été trouvée.");
Guid idCollaborateur = demandeFormation.Ep.IdCollaborateur; // devra être utilisé pour notifier le collaborateur
demandeFormation.Etat = demandeFormationDTO.EtatDemande;
demandeFormation.CommentaireRefus = demandeFormationDTO.CommentaireRefus;
demandeFormation.DateDerniereReponse = DateTime.Now;
if (demandeFormation.ParticipationFormation != null)
epContext.Remove(demandeFormation.ParticipationFormation);
await epContext.SaveChangesAsync();
if (demandeFormationDTO.Formation != null && demandeFormationDTO.Formation.Id.HasValue)
{
int nbParticipations = await epContext.ParticipationFormation.Include(p => p.DemandeFormation).Where(p => p.Formation.IdFormation == demandeFormationDTO.Formation.Id.Value).CountAsync();
demandeFormationDTO.Formation.NbParticipations = nbParticipations;
}
demandeFormationDTO.EtatDemande = demandeFormation.Etat;
demandeFormationDTO.DateDerniereReponse = demandeFormation.DateDerniereReponse;
return demandeFormationDTO;
}
/// <summary>
/// Vérifier si un objet DemandeFormationDTO est valide pour une mise à jour.
/// </summary>
/// <remarks>
/// Un objet DemandeFormationDTO est valide si l'objet n'est pas null, si le libellé, la descritpion,
/// la date de demande de début et la valeur permettant de dire si la demande a été créé par une RH ou non ne sont pas null.
/// </remarks>
/// <param name="demande"></param>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationInvalidException"></exception>
/// <returns>true si l'objet est valide, false sinon</returns>
private void IsDemandeFormationValide(DemandeFormationDTO demande)
{
// Vérifier que la demande de formation n'est pas null
if (demande == null)
throw new DemandeFormationInvalidException("Aucune évaluation n'a été reçue.");
// Vérifier que la demande de formation a bien un libellé
if (string.IsNullOrWhiteSpace(demande.Libelle))
throw new DemandeFormationInvalidException("Le libellé de la demande de formation doit contenir au moins 1 caractère.");
// Vérifier que la demande de formation a bien une description
if (string.IsNullOrWhiteSpace(demande.Description))
throw new DemandeFormationInvalidException("La description de la demande de formation doit contenir au moins 1 caractère.");
// Vérifier que la demande de formation a bien une valeur permettant de dire s'il s'agit d'une demande créée par une RH ou non
if (!demande.DemandeRH.HasValue)
throw new DemandeFormationInvalidException("Impossible de répondre à une demande de formation sans savoir si la demande a été créé par une RH ou non.");
// Vérifier que la demande de formation a bien une date de demande
if (!demande.DateDemande.HasValue)
throw new DemandeFormationInvalidException("Une date de demande de formation est requise.");
// Vérifier que la demande de formation a bien un collaborateur
if (demande.Collaborateur == null || !demande.Collaborateur.Id.HasValue)
throw new DemandeFormationInvalidException("Un collaborateur est requis pour une demande de formation.");
// Vérifier que la demande de formation a bien un collaborateur
if (demande.Origine == null || !demande.Origine.Id.HasValue)
throw new DemandeFormationInvalidException("Une origine de formation est requise pour une demande de formation.");
}
/// <summary>
/// Ajouter un ordonnancement croissant ou décroissant sur une colonne.
/// </summary>
/// <param name="query"></param>
/// <param name="asc"></param>
/// <param name="columnName"></param>
/// <returns></returns>
private IEnumerable<DemandeFormationDTO> OrderByColumn(IEnumerable<DemandeFormationDTO> query, bool? asc, string columnName)
{
if (!asc.HasValue)
asc = defaultAsc;
if (string.IsNullOrWhiteSpace(columnName))
return OrderByDefault(query, (bool)asc);
if ((bool)asc)
return OrderByAscending(query, columnName);
else
return OrderByDescending(query, columnName);
}
/// <summary>
/// Ajouter un ordonnancement croissant sur une colonne.
/// </summary>
/// <param name="query"></param>
/// <param name="columnName"></param>
/// <returns></returns>
private IEnumerable<DemandeFormationDTO> OrderByAscending(IEnumerable<DemandeFormationDTO> query, string columnName)
{
switch (columnName.ToLower())
{
case "businessunit":
return query.OrderBy(d => d.Collaborateur.BusinessUnit.Nom);
case "collaborateur":
return query.OrderBy(d => d.Collaborateur.Nom);
case "datedemande":
return query.OrderBy(d => d.DateDemande);
case "demanderh":
return query.OrderBy(d => d.DemandeRH);
case "etat":
return query.OrderBy(d => d.EtatDemande);
case "datereponse":
return query.OrderBy(d => d.DateDerniereReponse);
default:
return query.OrderBy(p => p.Collaborateur.Nom);
}
}
/// <summary>
/// Ajouter un ordonnancement décroissant sur une colonne.
/// </summary>
/// <param name="query"></param>
/// <param name="columnName"></param>
/// <returns></returns>
private IEnumerable<DemandeFormationDTO> OrderByDescending(IEnumerable<DemandeFormationDTO> query, string columnName)
{
switch (columnName.ToLower())
{
case "businessunit":
return query.OrderByDescending(d => d.Collaborateur.BusinessUnit.Nom);
case "collaborateur":
return query.OrderByDescending(d => d.Collaborateur.Nom);
case "datedemande":
return query.OrderByDescending(d => d.DateDemande);
case "demanderh":
return query.OrderByDescending(d => d.DemandeRH);
case "etat":
return query.OrderByDescending(d => d.EtatDemande);
case "datereponse":
return query.OrderByDescending(d => d.DateDerniereReponse);
default:
return query.OrderByDescending(d => d.Collaborateur.Nom);
}
}
/// <summary>
/// Ajouter un ordonnancement par défaut.
/// </summary>
/// <param name="query"></param>
/// <param name="asc"></param>
/// <returns></returns>
private IEnumerable<DemandeFormationDTO> OrderByDefault(IEnumerable<DemandeFormationDTO> query, bool asc)
{
if (asc)
return query.OrderBy(p => p.Collaborateur.Nom);
else
return query.OrderByDescending(p => p.Collaborateur.Nom);
}
/// <summary>
/// Ajouter un filtre pour récupérer les demandes de formation en fonction du statut de l'EP.
/// </summary>
/// <param name="query"></param>
/// <param name="etatsDemande"></param>
/// <returns></returns>
private IQueryable<DemandeFormation> StatutEpFilter(IQueryable<DemandeFormation> query)
{
IEnumerable<StatutEp> statutsEp = Enum.GetValues(typeof(StatutEp)).Cast<StatutEp>().Where(statut => statut == StatutEp.Cree || EstEpEnCours(statut));
return query.Where(demandeFormation => statutsEp.Contains(demandeFormation.Ep.Statut));
}
/// <summary>
/// Ajouter un filtre pour récupérer les demandes de formation en fonction de plusieurs états de demande.
/// </summary>
/// <param name="query"></param>
/// <param name="etatsDemande"></param>
/// <returns></returns>
private IQueryable<DemandeFormation> EtatsDemandeFilter(IQueryable<DemandeFormation> query, List<EtatDemande> etatsDemande)
{
if (etatsDemande != null && etatsDemande.Count > 0)
return query.Where(demandeFormation => etatsDemande.Contains(demandeFormation.Etat));
else
return query;
}
/// <summary>
/// Ajouter un filtre pour récupérer les demandes de formation en fonction de l'id BU des collaborateurs.
/// </summary>
/// <param name="query"></param>
/// <param name="idBus"></param>
/// <returns></returns>
private IQueryable<DemandeFormation> IdBUsFilter(IQueryable<DemandeFormation> query, List<long?> idBus)
{
if (idBus != null && idBus.Count > 0)
return query.Where(demandeFormation => idBus.Contains(demandeFormation.Ep.IdBu));
else
return query;
}
/// <summary>
/// Ajouter un filtre pour récupérer les formations en fonction d'un intervalle de date.
/// </summary>
/// <param name="query"></param>
/// <param name="dateDebut"></param>
/// <param name="dateFin"></param>
/// <returns></returns>
private IQueryable<DemandeFormation> DateFilter(IQueryable<DemandeFormation> query, DateTime? dateDebut, DateTime? dateFin)
{
if (dateDebut.HasValue && dateFin.HasValue)
return query.Where(demandeFormation => demandeFormation.DateDemande >= dateDebut.Value && demandeFormation.DateDemande <= dateFin.Value.AddDays(1));
else if (!dateDebut.HasValue && dateFin.HasValue)
return query.Where(demandeFormation => demandeFormation.DateDemande <= dateFin.Value.AddDays(1));
else if (dateDebut.HasValue && !dateFin.HasValue)
return query.Where(demandeFormation => demandeFormation.DateDemande >= dateDebut.Value);
else
return query;
}
/// <summary>
/// Ajouter un filtre pour récupérer les demandes de formation en fonction du nom et du prénom du collaborateur.
/// </summary>
/// <param name="demandeFormationDTOs"></param>
/// <param name="intitule"></param>
/// <returns></returns>
private IEnumerable<DemandeFormationDTO> CollaborateurFilter(IEnumerable<DemandeFormationDTO> demandeFormationDTOs, string texte)
{
if (string.IsNullOrWhiteSpace(texte))
return demandeFormationDTOs;
return demandeFormationDTOs.Where(demandeFormation => (demandeFormation.Ep.Collaborateur.Nom + " " + demandeFormation.Ep.Collaborateur.Prenom).ToLower().Contains(texte.ToLower()) ||
(demandeFormation.Ep.Collaborateur.Prenom + " " + demandeFormation.Ep.Collaborateur.Nom).ToLower().Contains(texte.ToLower()));
}
/// <summary>
/// Ajouter une pagination.
/// </summary>
/// <param name="query"></param>
/// <param name="parPage"></param>
/// <param name="numPage"></param>
/// <returns></returns>
private IQueryable<DemandeFormation> SkipAndTake(IQueryable<DemandeFormation> query, int? parPage, int? numPage)
{
int skip, take;
if (!parPage.HasValue || parPage.Value < minParPage || parPage.Value > maxParPage)
parPage = defaultParPage;
if (!numPage.HasValue || numPage.Value <= 0)
numPage = defaultNumPage;
skip = (numPage.Value - 1) * parPage.Value;
take = parPage.Value;
return query.Skip(skip).Take(take);
}
private bool EstEpEnCours(StatutEp statut)
{
return statut != StatutEp.Annule && statut != StatutEp.Cree && statut != StatutEp.Rejete && statut != StatutEp.Signe;
}
#endregion
}
}