Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StageDTO"/> class
 /// </summary>
 /// <param name="stageEvent">A <see cref="stageSummaryEndpoint"/> containing basic information about the event</param>
 internal StageDTO(stageSummaryEndpoint stageEvent)
     : base(stageEvent)
 {
     if (stageEvent.sport_event == null)
     {
         return;
     }
     if (stageEvent.sport_event.races != null && stageEvent.sport_event.races.Any())
     {
         Stages = stageEvent.sport_event.races.Select(s => new StageDTO(s));
     }
     if (stageEvent.sport_event?.tournament != null)
     {
         Tournament = new TournamentDTO(stageEvent.sport_event.tournament);
     }
     if (stageEvent.sport_event.parent != null)
     {
         ParentStage = new StageDTO(stageEvent.sport_event.parent);
     }
     if (ParentStage == null && Type != null && Type == SportEventType.Parent && stageEvent.sport_event.tournament != null)
     {
         ParentStage = new StageDTO(new TournamentDTO(stageEvent.sport_event.tournament));
     }
     if (!stageEvent.sport_event.additional_parents.IsNullOrEmpty())
     {
         AdditionalParents = stageEvent.sport_event.additional_parents.Select(s => new StageDTO(s));
     }
 }
Ejemplo n.º 2
0
        internal FixtureDTO(fixture fixture, DateTime?generatedAt)
            : base(fixture)
        {
            Guard.Argument(fixture, nameof(fixture)).NotNull();

            StartTime = fixture.start_timeSpecified
                ? (DateTime?)fixture.start_time.ToLocalTime()
                : null;
            if (!string.IsNullOrEmpty(fixture.next_live_time))
            {
                NextLiveTime = SdkInfo.ParseDate(fixture.next_live_time);
            }
            StartTimeConfirmed = fixture.start_time_confirmedSpecified && fixture.start_time_confirmed;
            ExtraInfo          = fixture.extra_info != null && fixture.extra_info.Any()
                ? new ReadOnlyDictionary <string, string>(fixture.extra_info.ToDictionary(e => e.key, e => e.value))
                : null;
            TvChannels = fixture.tv_channels != null && fixture.tv_channels.Any()
                ? new ReadOnlyCollection <TvChannelDTO>(fixture.tv_channels.Select(t => new TvChannelDTO(t)).ToList())
                : null;
            ProductInfo = fixture.product_info != null
                ? new ProductInfoDTO(fixture.product_info)
                : null;
            Venue = fixture.venue == null
                ? null
                : new VenueDTO(fixture.venue);
            ReferenceIds = fixture.reference_ids == null
                ? null
                : new ReadOnlyDictionary <string, string>(fixture.reference_ids.ToDictionary(r => r.name, r => r.value));
            DelayedInfo = fixture.delayed_info == null
                ? null
                : new DelayedInfoDTO(fixture.delayed_info.id, fixture.delayed_info.description);
            if (fixture.scheduled_start_time_changes != null && fixture.scheduled_start_time_changes.Any())
            {
                ScheduledStartTimeChanges = fixture.scheduled_start_time_changes.Select(s => new ScheduledStartTimeChangeDTO(s));
            }
            if (generatedAt != null)
            {
                GeneratedAt = generatedAt.Value.ToLocalTime();
            }
            if (fixture.parent != null)
            {
                ParentStage = new StageDTO(fixture.parent);
            }
            if (ParentStage == null && Type != null && Type == SportEventType.Parent && fixture.tournament != null)
            {
                ParentStage = new StageDTO(new TournamentDTO(fixture.tournament));
            }
            if (!fixture.additional_parents.IsNullOrEmpty())
            {
                AdditionalParents = fixture.additional_parents.Select(s => new StageDTO(s));
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StageDTO"/> class
 /// </summary>
 /// <param name="stageEvent">A <see cref="stageSummaryEndpoint"/> containing basic information about the event</param>
 internal StageDTO(stageSummaryEndpoint stageEvent)
     : base(stageEvent)
 {
     if (stageEvent.sport_event.parent != null)
     {
         ParentStage = new StageDTO(stageEvent.sport_event.parent);
     }
     if (stageEvent.sport_event.races != null && stageEvent.sport_event.races.Any())
     {
         Stages = stageEvent.sport_event.races.Select(s => new StageDTO(s));
     }
     if (stageEvent.sport_event?.tournament != null)
     {
         Tournament = new TournamentDTO(stageEvent.sport_event.tournament);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StageDTO"/> class
 /// </summary>
 /// <param name="sportEvent">A <see cref="sportEvent"/> containing basic information about the event</param>
 internal StageDTO(sportEvent sportEvent)
     : base(sportEvent)
 {
     if (sportEvent.parent != null)
     {
         ParentStage = new StageDTO(sportEvent.parent);
     }
     if (sportEvent.races != null && sportEvent.races.Any())
     {
         Stages = sportEvent.races.Select(s => new StageDTO(s));
     }
     if (sportEvent.tournament != null)
     {
         Tournament = new TournamentDTO(sportEvent.tournament);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="StageDTO" /> class
 /// </summary>
 /// <param name="stageEvent">A <see cref="stageSummaryEndpoint" /> containing basic information about the event</param>
 internal StageDTO(stageSummaryEndpoint stageEvent)
     : base(stageEvent)
 {
     if (stageEvent.sport_event.parent != null)
     {
         ParentStage = new StageDTO(stageEvent.sport_event.parent);
     }
     if (stageEvent.sport_event.races != null && stageEvent.sport_event.races.Any())
     {
         Stages = stageEvent.sport_event.races.Select(s => new StageDTO(s));
     }
     if (stageEvent.sport_event?.tournament != null)
     {
         Contract.Assume(!string.IsNullOrEmpty(stageEvent.sport_event.tournament.id));
         Contract.Assume(!string.IsNullOrEmpty(stageEvent.sport_event.tournament.name));
         Tournament = new TournamentDTO(stageEvent.sport_event.tournament);
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StageDTO"/> class
 /// </summary>
 /// <param name="sportEvent">A <see cref="sportEvent"/> containing basic information about the event</param>
 internal StageDTO(sportEvent sportEvent)
     : base(sportEvent)
 {
     if (sportEvent.races != null && sportEvent.races.Any())
     {
         Stages = sportEvent.races.Select(s => new StageDTO(s));
     }
     if (sportEvent.tournament != null)
     {
         Tournament = new TournamentDTO(sportEvent.tournament);
     }
     if (sportEvent.parent != null)
     {
         ParentStage = new StageDTO(sportEvent.parent);
     }
     if (ParentStage == null && Type != null && Type == SportEventType.Parent && sportEvent.tournament != null)
     {
         ParentStage = new StageDTO(new TournamentDTO(sportEvent.tournament));
     }
     if (sportEvent.additional_parents != null && sportEvent.additional_parents.Any())
     {
         AdditionalParents = sportEvent.additional_parents.Select(s => new StageDTO(s));
     }
 }