Example #1
0
        private ProgressStatus GetGameStatus(ActiveMultiLegProductForTimeline game, IList <Race> races)
        {
            List <Race> gameRaces = races.Where(x => game.Races.Contains(x.RaceNumber)).ToList();

            if (game.IsAbandoned)
            {
                return(ProgressStatus.Abandoned);
            }

            if (gameRaces.All(x => x.ProgressStatus == ProgressStatus.Finished))
            {
                return(ProgressStatus.Finished);
            }

            if (gameRaces.All(x => x.ProgressStatus == ProgressStatus.Future))
            {
                return(ProgressStatus.Future);
            }

            return(ProgressStatus.Ongoing);
        }
Example #2
0
        private IEnumerable <ConsecutiveLegsForMultiLegGame> CalculateConsecutiveLegs(ActiveMultiLegProductForTimeline game)
        {
            int previousRace = game.Races.First();

            var consecutiveLegs = new ConsecutiveLegsForMultiLegGame
            {
                FromRaceNumber = previousRace,
                ToRaceNumber   = previousRace
            };

            foreach (int currentRace in game.Races.Skip(1))
            {
                if (currentRace == previousRace + 1)
                {
                    consecutiveLegs.ToRaceNumber = currentRace;
                    previousRace = currentRace;
                }
                else
                {
                    yield return(consecutiveLegs);

                    consecutiveLegs = new ConsecutiveLegsForMultiLegGame
                    {
                        FromRaceNumber = currentRace,
                        ToRaceNumber   = currentRace
                    };

                    previousRace = currentRace;
                }
            }

            yield return(consecutiveLegs);
        }