//vérifie si il y a un transfert après le match si et seulement si le match est avant l'intersaison (le classement n'intervient que dans la condition de transfert en intersaison) public static bool checkTransfertApres(Guid matchId) { try { MatchsService match = new MatchsService(); DateTime dateMatch = match.getMatchDate(matchId); IntersaisonsService inter = new IntersaisonsService(); DateTime dateDebutIntersaison = inter.GetDateDebut(dateMatch.Year); DateTime dateFinIntersaison = inter.GetDateFin(dateMatch.Year); if (dateDebutIntersaison > dateMatch) { ChampionnatsService cs = new ChampionnatsService(); Guid championnatId = cs.GetListeObject().FirstOrDefault(x => x.annee == dateMatch.Year).championnatId; EquipesParticipationsService eps = new EquipesParticipationsService(); List <EquipesModele> lEquipe = eps.getEquipesParticipantes(championnatId); TransfertsHistoryService ths = new TransfertsHistoryService(); List <TransfertsModele> lTransferts = ths.GetListeObject().Where(x => (x.dateDebut >= dateDebutIntersaison && x.dateDebut <= dateFinIntersaison) || (x.dateFin >= dateDebutIntersaison && x.dateFin <= dateFinIntersaison)) .ToList(); foreach (TransfertsModele transfert in lTransferts) { if (lEquipe.Any(x => x.equipeId == transfert.equipeId)) { return(true); } } } return(false); } catch (Exception ex) { throw ex; } }
// A partir de l'equipeID et du matchID renvoie la feuille de match existante ou un vide si jamais elle n'existe pas public static DataTable getMatchEquipe(Guid equipeId, Guid matchId, DateTime matchDate) { try { // récupère feuilleID si il existe ou en crée un FeuillesMatchService fms = new FeuillesMatchService(); Guid feuilleId = fms.UpdateFeuille(matchId, equipeId); // récupère les joueurs déjà inscrits List <dynamic> lstDy = new List <dynamic>(); lstDy.Add(feuilleId); JoueursParticipationService jps = new JoueursParticipationService(); DataView jpv = jps.loadWithParameter("JoueursInscrits", lstDy); //récupère les joueurs dans l'équipe au moment du match List <dynamic> lstDy2 = new List <dynamic>(); lstDy2.Add(equipeId); lstDy2.Add(matchDate); TransfertsHistoryService ths = new TransfertsHistoryService(); DataView thv = ths.loadWithParameter("JoueursEquipe", lstDy2); JoueursService js = new JoueursService(); DataView jv = js.loadAllData(); CartesJaunesService cjs = new CartesJaunesService(); DataView cjv = cjs.loadAllData(); CartesRougesService crs = new CartesRougesService(); DataView crv = crs.loadAllData(); QuartersService qs = new QuartersService(); QuartersModele quarter = qs.getAQuarter(matchDate); //obtient la liste de match de l'équipe pour le quarter et triée par date ascendante MatchsService ms = new MatchsService(); DataView mv = ms.loadAllData(); List <MatchsModele> lMatchs = ms.getMatchsEquipe(equipeId, quarter); DataTable feuille = new TableFeuilleMatch().getTable(); DataRow row; foreach (DataRowView dr in thv) { row = feuille.NewRow(); //va chercher le prénom et le nom du joueur int i = 0; while ((Guid)dr["joueurId"] != (Guid)jv[i]["joueurId"]) { i++; } row[0] = (String)jv[i]["prenom"] + " " + (String)jv[i]["nom"]; //va chercher le nombre de cartons jaunes actifs dans le quarter row[1] = CountCartesJaunesActives((Guid)dr["joueurId"], equipeId, quarter); //va chercher le nombre de suspensions restantes à un carton rouge dans le quarter row[2] = 0; //récupère la liste de cartons rouge du joueur pour le quarter List <Guid> lMatchsAvecCartons = crs.getMatchsCartonsRouges((Guid)dr["joueurId"], quarter); //vérifie si il en a reçu if (lMatchsAvecCartons.Any()) { int positionMatch = lMatchs.IndexOf(lMatchs.Where(xx => xx.matchDate == matchDate) .FirstOrDefault()); foreach (Guid Id in lMatchsAvecCartons) { int positionCarton = lMatchs.IndexOf(lMatchs.Where(xx => xx.matchId == Id) .FirstOrDefault()); //vérifie que le match en cours est affecté par le carton if (positionMatch - positionCarton > 0 && positionMatch - positionCarton < 3) { row[2] = 4 - positionMatch - positionCarton; } } } //va chercher le nombre de match restants pour l'équipe ce quarter row[3] = lMatchs.Where(xx => xx.isPlayed == false) .Count(); // va voir si le joueur est déjà sur la feuille de match row[4] = false; for (i = 0; i < jpv.Count; i++) { if ((Guid)dr["joueurId"] == (Guid)jpv[i]["joueurId"]) { row[4] = true; } } // rajoute le joueurId pour contrôle row[5] = (Guid)dr["joueurId"]; feuille.Rows.Add(row); } feuille.AcceptChanges(); return(feuille); } catch (TechnicalError ce) { throw ce; } catch (Exception ex) { throw ex; } }