Exemplo n.º 1
0
        public static DataView fillInCartesRouges(Guid equipeId, Guid matchId)
        {
            try
            {
                CartesRougesService crs = new CartesRougesService();
                DataView            crv = crs.loadAllData();

                JoueursService js = new JoueursService();
                DataView       jv = js.loadAllData();

                TableResultats tabResult = new TableResultats();

                DataTable tableResults = tabResult.getTableResultats();

                DataRow row;

                foreach (DataRowView dr in crv)
                {
                    if ((Guid)dr["matchId"] == matchId && (Guid)dr["equipeId"] == equipeId)
                    {
                        row = tableResults.NewRow();

                        row[0] = (Guid)dr["joueurId"];

                        row[1] = "";

                        int i = 0;

                        while (((Guid)dr["joueurId"] != (Guid)jv[i]["joueurId"]) && i < jv.Count)
                        {
                            i++;
                        }
                        if (i != jv.Count)
                        {
                            row[1] = jv[i]["prenom"] + " " + jv[i]["nom"];
                        }

                        row[2] = dr["minuteRecue"];

                        row[3] = (Guid)dr["carteRougeId"];

                        DateTime date = DateTime.Now;

                        row[4] = date;

                        tableResults.Rows.Add(row);
                    }
                }
                tableResults.AcceptChanges();
                return(tableResults.DefaultView);
            }
            catch (TechnicalError ce)
            {
                throw ce;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public static List <MatchsModele> getListeMatchExclusionCartonRouge(Guid joueurId, Guid equipeId, QuartersModele quarter)
        {
            try
            {
                MatchsService ms = new MatchsService();

                //obtient la liste des matchs joués par l'équipe du joueur en ordre chronologique ce quarter
                List <MatchsModele> lMatchsEquipe = ms.getMatchParticipationParUneEquipeParQuarter(equipeId, quarter.dateDebut, quarter.dateFin).OrderBy(x => x.matchDate).ToList();

                CartesRougesService cs = new CartesRougesService();

                //obtient la liste des matchs avec cartons rouges du joueur dans le quarter
                List <Guid> lmatchsAvecCartonsRouges = cs.getMatchsCartonsRouges(joueurId, quarter);

                List <MatchsModele> lMatchsExclusionJoueur = new List <MatchsModele>();

                //vérifie si il y a des matchs avec cartons rouges
                if (lmatchsAvecCartonsRouges.Any())
                {
                    foreach (Guid matchId in lmatchsAvecCartonsRouges)
                    {
                        int ind = lMatchsEquipe.IndexOf(lMatchsEquipe.First(x => x.matchId == matchId));
                        int i   = ind++;
                        while (i < lMatchsEquipe.Count && i < ind + 3)
                        {
                            lMatchsExclusionJoueur.Add(lMatchsEquipe[i]);
                            i++;
                        }
                    }
                }

                return(lMatchsExclusionJoueur);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        // 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;
            }
        }