public List <DistanceRaceCategorie> GetDistanceCategoryRaceByIdParticipant(int idParticipant)
        {
            List <DistanceRaceCategorie> distanceByRace = new List <DistanceRaceCategorie>();

            using (DbTools cnx = new DbTools())
            {
                using (DbCommand command = cnx.CreerRequete(RQT_GET_TOTAL_RACE))
                {
                    cnx.CreerParametre(command, "@idParticipant", idParticipant);
                    using (DbDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            distanceByRace.Add(new DistanceRaceCategorie
                            {
                                Distance        = reader.GetInt32(reader.GetOrdinal("distance")),
                                Categorie       = reader.GetInt32(reader.GetOrdinal("IdCategorieCourse")),
                                CategorieString = reader.GetString(reader.GetOrdinal("Libelle")),
                            });
                        }
                    }
                }
            }
            return(distanceByRace);
        }
        public void Remove(int id)
        {
            DbTools   cnx     = new DbTools();
            DbCommand command = cnx.CreerRequete("DELETE FROM Inscription WHERE Id= @id;");

            cnx.CreerParametre(command, "@id", id);
            command.ExecuteNonQuery();
        }
        /// <summary>
        /// Permet de retourner le nombre total d'inscri a une course
        /// </summary>
        /// <param name="idCourse"></param>
        /// <returns></returns>
        public int GetCountInscriByCourse(int idCourse)
        {
            int count = 0;

            using (DbTools cnx = new DbTools())
            {
                using (DbCommand command = cnx.CreerRequete(RQT_COUNT_INSCRIPTION))
                {
                    cnx.CreerParametre(command, "@idCourse", idCourse);
                    count = (int)command.ExecuteScalar();
                }
            }
            return(count);
        }
        /// <summary>
        /// Permet de récupérer les statistiques de chaque course du participant, par catégorie.
        /// </summary>
        /// <param name="idParticipant">Contient l'id du participant</param>
        /// <param category="catId">Contient l'id de la catégorie</param>
        /// <returns></returns>
        public List <UserStats> getStatsByCategory(int idParticipant, int catId)
        {
            List <UserStats> listStats = new List <UserStats>();

            var instance = new DbTools();
            var command  = instance.CreerRequete(RQT_GET_STATS);

            instance.CreerParametre(command, "@idParticipant", idParticipant);
            instance.CreerParametre(command, "@catId", catId);

            using (DbDataReader reader = command.ExecuteReader())
            {
                listStats = BuildListUserStats(reader);
            }

            if (listStats.Count > 0)
            {
                foreach (UserStats list in listStats)
                {
                    var commandFastestSpeed = instance.CreerRequete(RQT_GET_FASTEST_TIME);
                    instance.CreerParametre(commandFastestSpeed, "@idCourse", list.IdCourse);

                    using (DbDataReader readerFastestSpeed = commandFastestSpeed.ExecuteReader())
                    {
                        list.FastestTime = BuildFastestTime(readerFastestSpeed);
                        if (list.FastestTime != null)
                        {
                            list.FastestSpeed = CalculSpeed(list.Distance, list.FastestTime.Value);
                        }
                    }

                    var commandAverageSpeed = instance.CreerRequete(RQT_GET_AVERAGE_TIME);
                    instance.CreerParametre(commandAverageSpeed, "@idCourse", list.IdCourse);

                    using (DbDataReader readerAverageSpeed = commandAverageSpeed.ExecuteReader())
                    {
                        var averageTime = BuildAverageTime(readerAverageSpeed);
                        if (averageTime != null)
                        {
                            list.AverageSpeed = CalculSpeed(list.Distance, averageTime.Value);
                        }
                    }
                }
            }

            return(listStats);
        }
        /// <summary>
        /// Récupère la liste des ids de chaque catégories.
        /// </summary>
        /// <returns></returns>
        public List <int> getCategoriesId()
        {
            List <int> listCategoriesId = new List <int>();

            var instance = new DbTools();
            var command  = instance.CreerRequete(RQT_GET_CATEGORY_ID);

            using (DbDataReader reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    listCategoriesId.Add(reader.GetInt32(reader.GetOrdinal("Id")));
                }
            }

            return(listCategoriesId);
        }
        /// <summary>
        /// Permet de récupérer la liste des 3 dernieres inscriptions d'un participant
        /// </summary>
        /// <param name="idParticipant">Contient l'id du participant</param>
        /// <returns></returns>
        public List <InscriRaceSuivi> GetLast3Race(int idParticipant)
        {
            List <InscriRaceSuivi> racesInscri = null;

            //Récuperation de la connexion et création de la commande
            DbTools   instance = new DbTools();
            DbCommand command  = instance.CreerRequete(RQT_GET_LAST_3_INSCRI);

            //Ajout du parametre idParticipant
            instance.CreerParametre(command, "@idParticipant", idParticipant);

            using (DbDataReader reader = command.ExecuteReader())
            {
                racesInscri = BuildListInscriRaceSuivi(reader);
            }

            return(racesInscri);
        }