コード例 #1
0
        //ajoute et supprime les participations nécessaires (qui ont été modifiées)
        public void SaveAll(DataView oView, Guid matchId, Guid equipeId)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    FeuillesMatchService fs = new FeuillesMatchService();
                    Guid feuilleID          = fs.UpdateFeuille(matchId, equipeId);

                    this.AddAll(oView, feuilleID);
                    this.DeleteAll(oView, feuilleID);

                    scope.Complete();
                }
            }

            catch (TechnicalError oErreur)
            {
                throw oErreur;
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        public static List <JoueursModele> getJoueurs(Guid matchId, Guid equipeId)
        {
            try
            {
                FeuillesMatchService fms = new FeuillesMatchService();
                DataView             fmv = fms.loadAllData();

                JoueursParticipationService jps = new JoueursParticipationService();
                DataView jpv = jps.loadAllData();

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


                TableResultats tabResult    = new TableResultats();
                DataTable      tableResults = tabResult.getTableResultatsCombo();
                DataRow        row;


                for (int i = 0; i < fmv.Count; i++)
                {
                    if ((Guid)fmv[i]["matchId"] == matchId && (Guid)fmv[i]["equipeId"] == equipeId)
                    {
                        for (int j = 0; j < jpv.Count; j++)
                        {
                            if ((Guid)fmv[i]["feuilleId"] == (Guid)jpv[j]["feuilleId"])

                            {
                                int k = 0;

                                while ((Guid)jpv[j]["joueurid"] != (Guid)jv[k]["joueurId"] && k < jv.Count)
                                {
                                    k++;
                                }

                                row = tableResults.NewRow();

                                row[0] = (jv[k]["joueurId"]);
                                row[1] = (jv[k]["nom"]);
                                row[2] = (jv[k]["prenom"]);
                                row[3] = (jv[k]["lastUpdate"]);

                                tableResults.Rows.Add(row);
                            }
                        }
                    }
                }

                tableResults.AcceptChanges();
                return(js.GetListeObject(tableResults));
            }
            catch (TechnicalError ce)
            {
                throw ce;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public static bool CheckNombreJoueurFeuillePasAssez(Guid equipeAId, Guid equipeBId, Guid matchId)
        {
            try
            {
                FeuillesMatchService        fms = new FeuillesMatchService();
                JoueursParticipationService jps = new JoueursParticipationService();

                if (fms.FeuilleExiste(matchId))
                {
                    int countJoueurEquipeA = jps.getCountJoueur(fms.GetFeuille(matchId, equipeAId).feuilleId);
                    int countJoueurEquipeB = jps.getCountJoueur(fms.GetFeuille(matchId, equipeBId).feuilleId);

                    if (countJoueurEquipeA >= NBMINJOUEUR && countJoueurEquipeB >= NBMINJOUEUR)
                    {
                        return(false);
                    }
                }
                else
                {
                    BusinessError be = new BusinessError("Aucune feuille de match n'existe pour ce match, merci de les remplir avant");
                    throw be;
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
        public static bool CheckFeuilleApres(Guid equipeAId, Guid equipeBId, Guid matchId)
        {
            try
            {
                MatchsService match     = new MatchsService();
                DateTime      dateMatch = match.getMatchDate(matchId);

                MatchsService       ms      = new MatchsService();
                List <MatchsModele> lMatchs = ms.GetListeObject().Where(x => x.matchDate.Year == dateMatch.Year &&
                                                                        x.matchDate > dateMatch &&
                                                                        (x.equipe1Id == equipeAId ||
                                                                         x.equipe1Id == equipeBId ||
                                                                         x.equipe2Id == equipeAId ||
                                                                         x.equipe2Id == equipeBId))
                                              .ToList();
                FeuillesMatchService         fms           = new FeuillesMatchService();
                List <FeuillesDeMatchModele> lFeuilleMatch = fms.GetListeObject();

                foreach (FeuillesDeMatchModele feuille in lFeuilleMatch)
                {
                    if (lMatchs.Any(x => x.matchId == feuille.matchId))
                    {
                        return(true);
                    }
                }


                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
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;
            }
        }
コード例 #6
0
        public static DataTable getMatchEquipe(int annee)
        {
            try {
                MatchsService  ms = new MatchsService();
                EquipesService es = new EquipesService();
                GoalsService   gs = new GoalsService();
                JoueursParticipationService jps = new JoueursParticipationService();
                FeuillesMatchService        fms = new FeuillesMatchService();

                DataView mv  = ms.loadAllData();
                DataView ev  = es.loadAllData();
                DataView gv  = gs.loadAllData();
                DataView fmv = fms.loadAllData();

                DataTable tableNettoyee = new TableAccueilMatchs().getTable();
                DataRow   row;

                foreach (DataRowView dr in mv)
                {
                    DateTime dt = (DateTime)dr["matchDate"];
                    if (dt.Year == annee)
                    {
                        row = tableNettoyee.NewRow();

                        // rempli la colonne des dates de match
                        row[0] = dr["matchDate"];


                        // rempli la colonne du nom de l'équipe A
                        Boolean trouve = false;
                        int     i      = 0;
                        while (trouve == false)
                        {
                            if ((Guid)dr["equipe1Id"] == (Guid)ev[i]["equipeId"])
                            {
                                row[1] = ev[i]["nom"];
                                trouve = true;
                            }
                            i++;
                        }

                        // rempli la colonne du nom de l'équipe B
                        trouve = false;
                        i      = 0;
                        while (trouve == false)
                        {
                            if ((Guid)dr["equipe2Id"] == (Guid)ev[i]["equipeId"])
                            {
                                row[2] = ev[i]["nom"];
                                trouve = true;
                            }
                            i++;
                        }


                        // rempli la colonne du nombre de goal (en string)
                        int goalA = 0;
                        int goalB = 0;

                        for (int j = 0; j < gv.Count; j++)
                        {
                            if ((Guid)dr["matchId"] == (Guid)gv[j]["matchId"])
                            {
                                if ((Guid)gv[j]["equipeId"] == (Guid)dr["equipe1Id"])
                                {
                                    goalA++;
                                }
                            }
                        }

                        for (i = 0; i < gv.Count; i++)
                        {
                            if ((Guid)dr["matchId"] == (Guid)gv[i]["matchId"])
                            {
                                if ((Guid)gv[i]["equipeId"] == (Guid)dr["equipe2Id"])
                                {
                                    goalB++;
                                }
                            }
                        }

                        row[3] = goalA + " - " + goalB;

                        // rempli la colonne pour savoir si les feuilles de matchs sont bien remplies
                        row[4] = false;

                        int countA = 0;
                        int countB = 0;

                        List <dynamic> lstParamA = new List <dynamic>();
                        List <dynamic> lstParamB = new List <dynamic>();


                        for (i = 0; i < fmv.Count; i++)
                        {
                            if ((Guid)dr["matchId"] == (Guid)fmv[i]["matchId"])
                            {
                                if ((Guid)dr["equipe1Id"] == (Guid)fmv[i]["equipeId"])
                                {
                                    lstParamA.Add((Guid)fmv[i]["feuilleId"]);
                                    DataView oView = jps.loadWithParameter("PartA", lstParamA);
                                    countA = oView.Count;
                                }

                                if ((Guid)dr["equipe2Id"] == (Guid)fmv[i]["equipeId"])
                                {
                                    lstParamB.Add((Guid)fmv[i]["feuilleId"]);
                                    DataView oView = jps.loadWithParameter("PartB", lstParamB);
                                    countB = oView.Count;
                                }
                            }
                        }


                        if (countA > 4 && countB > 4)
                        {
                            row[4] = true;
                        }

                        // rempli la colonne pour savoir si les matchs sont joués ou forfaits
                        row[5] = dr["isPlayed"];

                        // rempli la colonne des matchId
                        row[6] = dr["matchId"];

                        tableNettoyee.Rows.Add(row);
                    }
                }

                return(tableNettoyee);
            }
            catch (TechnicalError ce)
            {
                throw ce;
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }