internal MatchTimelineDTO(matchTimelineEndpoint timeline)
        {
            Guard.Argument(timeline, nameof(timeline)).NotNull();
            Guard.Argument(timeline.sport_event, nameof(timeline.sport_event)).NotNull();

            SportEvent = RestMapperHelper.MapSportEvent(timeline.sport_event);

            if (timeline.coverage_info != null)
            {
                CoverageInfo = new CoverageInfoDTO(timeline.coverage_info);
            }

            if (timeline.sport_event_conditions != null)
            {
                SportEventConditions = new SportEventConditionsDTO(timeline.sport_event_conditions);
            }

            if (timeline.sport_event_status != null)
            {
                SportEventStatus = new SportEventStatusDTO(timeline.sport_event_status, null, RestMapperHelper.FillHomeAwayCompetitors(timeline.sport_event.competitors));
            }

            if (timeline.timeline != null && timeline.timeline.Length > 0)
            {
                BasicEvents = timeline.timeline.Select(s => new BasicEventDTO(s));
            }

            GeneratedAt = timeline.generated_atSpecified ? timeline.generated_at : (DateTime?)null;
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MatchDTO"/> class
        /// </summary>
        /// <param name="matchSummary">A <see cref="matchSummaryEndpoint"/> instance containing basic information about the sport event</param>
        internal MatchDTO(matchSummaryEndpoint matchSummary)
            : base(matchSummary)
        {
            Guard.Argument(matchSummary, nameof(matchSummary)).NotNull();

            if (matchSummary.sport_event.season != null)
            {
                Guard.Argument(matchSummary.sport_event.season.id, nameof(matchSummary.sport_event.season.id)).NotNull().NotEmpty();
                Guard.Argument(matchSummary.sport_event.season.name, nameof(matchSummary.sport_event.season.name)).NotNull().NotEmpty();
                Season = new SeasonDTO(matchSummary.sport_event.season);
            }
            if (matchSummary.sport_event.tournament_round != null)
            {
                Round = new RoundDTO(matchSummary.sport_event.tournament_round);
            }
            if (matchSummary.sport_event.tournament != null)
            {
                Guard.Argument(matchSummary.sport_event.tournament.id, nameof(matchSummary.sport_event.tournament.id)).NotNull().NotEmpty();
                Guard.Argument(matchSummary.sport_event.tournament.name, nameof(matchSummary.sport_event.tournament.name)).NotNull().NotEmpty();
                Tournament = new TournamentDTO(matchSummary.sport_event.tournament);
            }
            if (matchSummary.coverage_info != null)
            {
                Coverage = new CoverageInfoDTO(matchSummary.coverage_info);
            }
        }
Пример #3
0
        internal MatchTimelineDTO(matchTimelineEndpoint timeline)
        {
            Contract.Requires(timeline != null);
            Contract.Requires(timeline.sport_event != null);

            SportEvent = RestMapperHelper.MapSportEvent(timeline.sport_event);

            if (timeline.coverage_info != null)
            {
                CoverageInfo = new CoverageInfoDTO(timeline.coverage_info);
            }

            if (timeline.sport_event_conditions != null)
            {
                SportEventConditions = new SportEventConditionsDTO(timeline.sport_event_conditions);
            }

            if (timeline.sport_event_status != null)
            {
                SportEventStatus = new SportEventStatusDTO(timeline.sport_event_status, null,
                                                           RestMapperHelper.FillHomeAwayCompetitors(timeline.sport_event.competitors));
            }

            if (timeline.timeline != null && timeline.timeline.Length > 0)
            {
                BasicEvents = timeline.timeline.Select(s => new BasicEventDTO(s));
            }
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MatchDTO"/> class
        /// </summary>
        /// <param name="fixture">A <see cref="fixture"/> instance containing basic information about the sport event</param>
        /// <remarks>Not all properties are filled via fixture (i.e.Venue, Conditions,..)</remarks>
        internal MatchDTO(fixture fixture)
            : this(new matchSummaryEndpoint
        {
            sport_event = new sportEvent
            {
                id = fixture.id,
                name = fixture.name,
                type = fixture.type,
                scheduledSpecified = fixture.scheduledSpecified,
                scheduled = fixture.scheduled,
                scheduled_endSpecified = fixture.scheduled_endSpecified,
                scheduled_end = fixture.scheduled_end,
                liveodds = fixture.liveodds,
                season = fixture.season,
                tournament = fixture.tournament,
                tournament_round = fixture.tournament_round,
                competitors = fixture.competitors?.Select(t => new teamCompetitor
                {
                    abbreviation = t.abbreviation,
                    country = t.country,
                    id = t.id,
                    name = t.name,
                    qualifier = t.qualifier,
                    @virtual = t.@virtual,
                    virtualSpecified = t.virtualSpecified,
                    country_code = t.country_code,
                    reference_ids = t.reference_ids,
                    division = t.division,
                    divisionSpecified = t.divisionSpecified,
                    state = t.state
                }).ToArray(),
                parent = fixture.parent,
                races = fixture.races,
                status = fixture.status,
                replaced_by = fixture.replaced_by,
                next_live_time = fixture.next_live_time,
                sport_event_conditions = fixture.sport_event_conditions,
                start_time_tbdSpecified = fixture.start_time_tbdSpecified,
                start_time_tbd = fixture.start_time_tbd
            }
        })
        {
            Venue = fixture.venue == null
                ? null
                : new VenueDTO(fixture.venue);

            if (fixture.coverage_info != null)
            {
                Coverage = new CoverageInfoDTO(fixture.coverage_info);
            }
        }