/// <summary>
        /// This function convert the data give by ImportCsvBrut to Participation and transfer it to db
        /// </summary>
        /// <param name="dico"></param>
        /// <param name="course"></param>
        public static void Import(Dictionary <string, List <string> > dico, Course course)
        {
            ParticipationCSVToDB.CSVContainsRightColumnLabel(dico);

            ParticipationCSVToDB.CSVContainsColumnWithSameNumberOfElement(dico);

            Participation part;
            Coureur       coureur;

            // Save data in db
            IParticipationRepository repo = new ParticipationRepository();

            for (int i = 0; i < dico[dico.Keys.First()].Count; i++)
            {
                coureur = new Coureur(dico["nom"][i]
                                      , dico["prenom"][i]
                                      , dico["licence"][i]
                                      , dico["courriel"][i]
                                      , dico["sexe"][i]
                                      , Convert.ToDateTime(dico["annee_naissance"][i]));

                part             = new Participation();
                part.Course      = course;
                part.Participant = coureur;
                part.NumDossard  = Convert.ToInt32(dico["dossard"][i]);
                if (dico.Keys.Contains("temps"))
                {
                    part.Temps = Convert.ToDouble(dico["temps"][i].Replace('.', ','));
                }

                repo.Save(part);
            }
        }
Ejemplo n.º 2
0
        public void RemoveCoureur(Coureur coureur)
        {
            IParticipationRepository participationRepository = new ParticipationRepository();
            IList <Participation>    participations          = participationRepository.SearchParticipationByCoureurId(coureur.IdCoureur);

            foreach (Participation p in participations)
            {
                Session.Delete(p);
                Session.Flush();
            }
            Session.Delete(coureur);
            Session.Flush();
        }