Example #1
0
        public static TeamMatchDto AssembleDto(this TeamMatch match, TeamDto homeEntrant, TeamDto awayEntrant)
        {
            var dto = new TeamMatchDto
            {
                ID                       = match.ID,
                FixtureID                = match.TeamFixture.ID,
                CompetitionID            = match.TeamFixture.CompetitionID,
                CompetitionStageSequence = match.TeamFixture.CompetitionRound.CompetitionEvent.CompetitionStage.Sequence,
                Leg                      = match.Leg,
                Date                     = match.Date,
                MatchStatusID            = match.MatchStatusID,
                MatchCalculationEngineID = match.MatchCalculationEngineID,
                Pitch                    = match.Pitch.AssembleDto(),
                HomeEntrant              = homeEntrant,
                AwayEntrant              = awayEntrant,
                VenueTypeID              = match.VenueTypeID,
                Comment                  = match.Comment
            };

            dto.Round = match.TeamFixture.CompetitionRound.AssembleTeamDto();

            if (match.MatchStatusID.IsProcessedWithResult())
            {
                dto.HomeResult = match.AssembleMatchHomeScore();
                dto.AwayResult = match.AssembleMatchAwayScore();

                foreach (TeamMatchXGame playerMatchGame in match.Games)
                {
                    var gameDto = playerMatchGame.Game.AssembleDto();
                    dto.Games.Add(gameDto);
                }
            }

            return(dto);
        }