예제 #1
0
        public static CategoryRaceModel ToModel(this CategoryRace bo)
        {
            if (bo == null)
            {
                return(null);
            }

            return(new CategoryRaceModel
            {
                Id = bo.Id,
                Title = bo.Title
            });
        }
예제 #2
0
        public static CategorieCourse ToDataEntity(this CategoryRace model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new CategorieCourse
            {
                Id = model.Id,
                Libelle = model.Title
            });
        }
예제 #3
0
        public static CategoryRace ToCategoryRaceBo(this CategoryRace bo)
        {
            if (bo == null)
            {
                return(null);
            }

            return(new CategoryRace
            {
                Id = bo.Id,
                Title = bo.Title
            });
        }
예제 #4
0
        private List <Race> BuildRaceList(DbDataReader reader)
        {
            List <Race> list = new List <Race>();

            while (reader.Read())
            {
                var raceId = reader.GetInt32(reader.GetOrdinal("CId"));

                Race r;
                if (list.All(x => x.Id != raceId))
                {
                    r = new Race
                    {
                        Id             = raceId,
                        Title          = reader.GetString(reader.GetOrdinal("CTitre")),
                        Description    = reader.GetString(reader.GetOrdinal("CDescription")),
                        DateStart      = reader.GetDateTime(reader.GetOrdinal("CDateStart")),
                        Town           = reader.GetString(reader.GetOrdinal("CVille")),
                        Distance       = reader.GetInt32(reader.GetOrdinal("CDistance")),
                        IdDifficulte   = reader.GetInt32(reader.GetOrdinal("CIdDifficulte")),
                        IdCategoryRace = reader.GetInt32(reader.GetOrdinal("CIdCategorieCourse")),
                        Difficulte     = new BO.Difficulte(),
                        CategoryRace   = new CategoryRace(),
                        Competitors    = new List <Competitor>()
                    };
                    list.Add(r);
                }
                else
                {
                    r = list.Single(x => x.Id == raceId);
                }

                // Récupération de la difficulte
                var difficulte = reader.GetInt32(reader.GetOrdinal("CIdDifficulte"));
                if (difficulte != 0)
                {
                    BO.Difficulte d = new BO.Difficulte
                    {
                        Id      = reader.GetInt32(reader.GetOrdinal("DId")),
                        Libelle = reader.GetString(reader.GetOrdinal("DLibelle")),
                    };
                    r.Difficulte = d;
                }

                // Récupération de la catégorie
                var categorie = reader.GetInt32(reader.GetOrdinal("CIdCategorieCourse"));
                if (categorie != 0)
                {
                    CategoryRace ca = new CategoryRace
                    {
                        Id    = reader.GetInt32(reader.GetOrdinal("CAId")),
                        Title = reader.GetString(reader.GetOrdinal("CALibelle")),
                    };
                    r.CategoryRace = ca;
                }

                // Récupération du type de participants
                var isCompetitor = reader.GetBoolean(reader.GetOrdinal("PctEstCompetiteur"));
                var isOrganiser  = reader.GetBoolean(reader.GetOrdinal("PctEstOrganisateur"));
                if (isCompetitor)
                {
                    Competitor c = new Competitor
                    {
                        Id            = reader.GetInt32(reader.GetOrdinal("PId")),
                        Nom           = reader.GetString(reader.GetOrdinal("PNom")),
                        Prenom        = reader.GetString(reader.GetOrdinal("PPrenom")),
                        Email         = reader.GetString(reader.GetOrdinal("PEmail")),
                        Phone         = reader.GetString(reader.GetOrdinal("PTelephone")),
                        DateNaissance = reader.GetDateTime(reader.GetOrdinal("PDateNaissance")),
                        Race          = r
                    };
                    r.Competitors.Add(c);
                }

                if (isOrganiser)
                {
                    Organizer o = new Organizer
                    {
                        Id            = reader.GetInt32(reader.GetOrdinal("PId")),
                        Nom           = reader.GetString(reader.GetOrdinal("PNom")),
                        Prenom        = reader.GetString(reader.GetOrdinal("PPrenom")),
                        Email         = reader.GetString(reader.GetOrdinal("PEmail")),
                        Phone         = reader.GetString(reader.GetOrdinal("PTelephone")),
                        DateNaissance = reader.GetDateTime(reader.GetOrdinal("PDateNaissance"))
                    };
                }
            }

            return(list);
        }