Esempio n. 1
1
        public SeasonWeek AddWeekToSeason(int seasonId, IList<RealWorldFixture> fixtures)
        {
            var season = LoadSeason(seasonId);

            var currentFinalWeek = season.Weeks.Any() ? season.Weeks.Max(w => w.WeekNumber) : 0;

            if (currentFinalWeek == season.NumberOfWeeks)
                throw new InvalidOperationException("Season has full complement of weeks already");

            var predsCutoffDate = fixtures.Min(f => f.KickOff).AddHours(-1);

            var addedWeek = new SeasonWeek
            {
                WeekNumber = currentFinalWeek + 1,
                RealWorldFixtures = fixtures,
                PredsCutOffDate = predsCutoffDate,
                Season = season,
            };

            foreach (var fixture in fixtures)
            {
                fixture.SeasonWeek = addedWeek;
            }

            season.Weeks.Add(addedWeek);
            _seasonRepository.Save(season);

            return addedWeek;
        }
Esempio n. 2
0
        public Week(SeasonWeek week)
        {
            WeekNumber = week.WeekNumber;
            Fixtures = new List<Fixture>();

            for (int i = 0; i < 10; i++)
            {
                Fixtures.Add(new Fixture(week.RealWorldFixtures.ElementAt(i)));
            }
        }