Exemple #1
0
        public static void SplitCareerSameName(string name, int startCareer2)
        {
            using (var db = new BeaujeauxEntities())
            {
                var skaters = db.Skaters.Where(a => a.Name == name);
                if (skaters.Count() != 1)
                {
                    throw new Exception("too many skaters");
                }
                var skater = skaters.First();

                skater.Name = name + " I";

                var secondSkater = new DataEF.Skater();
                secondSkater.Name = name + " II";
                db.Skaters.Add(secondSkater);

                db.SaveChanges();

                secondSkater = db.Skaters.Where(a => a.Name == name + " II").First();

                foreach (var season in skater.SkaterSeasonStats.Where(a => a.Season.Number >= startCareer2))
                {
                    season.SkaterId = secondSkater.Id;
                }

                db.SaveChanges();
            }
        }
Exemple #2
0
        private DataEF.SkaterSeasonStat SetSkaterStats(DataEF.Season dbSeason, DataEF.Skater dbSkater, SthsData.SkaterSeasonStats skaterStats)
        {
            var dbSeasonStats = new DataEF.SkaterSeasonStat()
            {
                Season = dbSeason,
                Skater = dbSkater,
                Team   = DataDB,
            };

            PopulateSkaterStats(dbSeasonStats, skaterStats);
            Database.SkaterSeasonStats.Add(dbSeasonStats);
            return(dbSeasonStats);
        }
Exemple #3
0
        private DataEF.Skater GetSkaterFromDB(SthsData.Skater sourceSkater)
        {
            var dbSkater = Database.Skaters
                           .Where(p => p.Name == sourceSkater.Name)
                           .FirstOrDefault();

            if (dbSkater == null)
            {
                dbSkater = new DataEF.Skater()
                {
                    Name = sourceSkater.Name,
                };
                Database.Skaters.Add(dbSkater);
            }
            return(dbSkater);
        }
Exemple #4
0
        private DataEF.SkaterSeasonStat SetSubtotalSkaterStats(DataEF.Season dbSeason, DataEF.Skater dbSkater, SthsData.SkaterSeasonStats skaterStats)
        {
            var dbSeasonSubtotalStats = new DataEF.SkaterSeasonStat()
            {
                Season     = dbSeason,
                Skater     = dbSkater,
                Team       = dbSeason.Teams.Where(a => a.Acronym == skaterStats.TeamAcronym).First(),
                IsSubtotal = true
            };

            PopulateSkaterStats(dbSeasonSubtotalStats, skaterStats);
            Database.SkaterSeasonStats.Add(dbSeasonSubtotalStats);
            return(dbSeasonSubtotalStats);
        }