Exemplo n.º 1
0
        public static TournamentDto FromTournament(ITournament tournament)
        {
            if (tournament == null)
            {
                return(null);
            }

            TournamentDto result = new TournamentDto()
            {
                ID                = tournament.ID,
                Name              = tournament.Name,
                NumLanes          = tournament.NumLanes,
                TrackLengthInches = tournament.TrackLengthInches,
                State             = tournament.State.ToString(),
                CurrentRace       = tournament.CurrentRace
            };

            foreach (ICar car in tournament.Cars)
            {
                result.Cars.Add(CarDto.FromCar(car));
            }

            foreach (IRace race in tournament.Races)
            {
                result.Races.Add(RaceDto.FromRace(race));
            }

            return(result);
        }
Exemplo n.º 2
0
        public static RaceDto FromRace(IRace race)
        {
            if (race == null)
            {
                return(null);
            }

            RaceDto result = new RaceDto()
            {
                RaceNumber = race.RaceNumber,
                State      = race.State.ToString()
            };

            foreach (ILaneAssignment laneAssignment in race.LaneAssignments)
            {
                result.LaneAssignments.Add(LaneAssignmentDto.FromLaneAssignment(laneAssignment));
            }

            return(result);
        }