/// <summary> /// Initializes a new instance of the <see cref="CompetitionDTO"/> class /// </summary> /// <param name="matchSummary">A <see cref="matchSummaryEndpoint"/> instance containing basic information about the sport event</param> internal CompetitionDTO(matchSummaryEndpoint matchSummary) : this(matchSummary.sport_event) { Guard.Argument(matchSummary, nameof(matchSummary)).NotNull(); Conditions = matchSummary.sport_event_conditions == null ? Conditions : new SportEventConditionsDTO(matchSummary.sport_event_conditions); SportEventStatus = matchSummary.sport_event_status == null ? null : new SportEventStatusDTO(matchSummary.sport_event_status, matchSummary.statistics, HomeAwayCompetitors); Venue = matchSummary.sport_event_conditions?.venue == null ? Venue : new VenueDTO(matchSummary.sport_event_conditions.venue); if (Venue == null && matchSummary.venue != null) { Venue = new VenueDTO(matchSummary.venue); } GeneratedAt = matchSummary.generated_atSpecified ? matchSummary.generated_at.ToLocalTime() : (DateTime?)null; }
/// <summary> /// Initializes a new instance of the <see cref="CompetitionDTO"/> class /// </summary> /// <param name="sportEvent">A <see cref="sportEvent"/> instance containing basic information about the sport event</param> internal CompetitionDTO(sportEvent sportEvent) : base(sportEvent) { BookingStatus?bookingStatus; if (RestMapperHelper.TryGetBookingStatus(sportEvent.liveodds, out bookingStatus)) { BookingStatus = bookingStatus; } if (sportEvent.competitors != null && sportEvent.competitors.Any()) { Competitors = new ReadOnlyCollection <TeamCompetitorDTO>(sportEvent.competitors.Select(c => new TeamCompetitorDTO(c)).ToList()); HomeAwayCompetitors = RestMapperHelper.FillHomeAwayCompetitors(sportEvent.competitors); } Conditions = sportEvent.sport_event_conditions == null ? null : new SportEventConditionsDTO(sportEvent.sport_event_conditions); Venue = sportEvent.sport_event_conditions?.venue == null ? null : new VenueDTO(sportEvent.sport_event_conditions.venue); if (Venue == null && sportEvent.venue != null) { Venue = new VenueDTO(sportEvent.venue); } }
/// <summary> /// Initializes a new instance of the <see cref="CompetitorProfileDTO"/> class /// </summary> /// <param name="record">A <see cref="competitorProfileEndpoint"/> containing information about the profile</param> public CompetitorProfileDTO(competitorProfileEndpoint record) { Guard.Argument(record, nameof(record)).NotNull(); Guard.Argument(record.competitor, nameof(record.competitor)).NotNull(); Competitor = new CompetitorDTO(record.competitor); if (record.players != null && record.players.Any()) { Players = new ReadOnlyCollection <PlayerProfileDTO>(record.players.Select(p => new PlayerProfileDTO(p, record.generated_atSpecified ? record.generated_at : (DateTime?)null)).ToList()); } if (record.jerseys != null) { Jerseys = new ReadOnlyCollection <JerseyDTO>(record.jerseys.Select(p => new JerseyDTO(p)).ToList()); } if (record.manager != null) { Manager = new ManagerDTO(record.manager); } if (record.venue != null) { Venue = new VenueDTO(record.venue); } if (record.race_driver_profile != null) { RaceDriverProfile = new RaceDriverProfileDTO(record.race_driver_profile); } }
/// <summary> /// Initializes a new instance of the <see cref="CompetitionDTO"/> class /// </summary> /// <param name="sportEvent">A <see cref="sportEvent"/> instance containing basic information about the sport event</param> internal CompetitionDTO(sportEvent sportEvent) : base(sportEvent) { if (RestMapperHelper.TryGetBookingStatus(sportEvent.liveodds, out var bookingStatus)) { BookingStatus = bookingStatus; } if (sportEvent.competitors != null && sportEvent.competitors.Any()) { Competitors = new ReadOnlyCollection <TeamCompetitorDTO>(sportEvent.competitors.Select(c => new TeamCompetitorDTO(c)).ToList()); HomeAwayCompetitors = RestMapperHelper.FillHomeAwayCompetitors(sportEvent.competitors); } Conditions = sportEvent.sport_event_conditions == null ? null : new SportEventConditionsDTO(sportEvent.sport_event_conditions); Venue = sportEvent.sport_event_conditions?.venue == null ? null : new VenueDTO(sportEvent.sport_event_conditions.venue); if (Venue == null && sportEvent.venue != null) { Venue = new VenueDTO(sportEvent.venue); } if (RestMapperHelper.TryGetSportEventType(sportEvent.type, out var type)) { Type = type; } if (!string.IsNullOrEmpty(sportEvent.liveodds)) { LiveOdds = sportEvent.liveodds; } if (RestMapperHelper.TryGetStageType(sportEvent.stage_type, out var stageType)) { StageType = stageType; } }
/// <summary> /// Initializes a new instance of the <see cref="CompetitionDTO"/> class /// </summary> /// <param name="matchSummary">A <see cref="matchSummaryEndpoint"/> instance containing basic information about the sport event</param> internal CompetitionDTO(matchSummaryEndpoint matchSummary) : this(matchSummary.sport_event) { Contract.Requires(matchSummary != null); Conditions = matchSummary.sport_event_conditions == null ? Conditions : new SportEventConditionsDTO(matchSummary.sport_event_conditions); Status = matchSummary.sport_event_status == null ? null : new SportEventStatusDTO(matchSummary.sport_event_status, matchSummary.statistics, HomeAwayCompetitors); Venue = matchSummary.sport_event_conditions?.venue == null ? Venue : new VenueDTO(matchSummary.sport_event_conditions.venue); if (Venue == null && matchSummary.venue != null) { Venue = new VenueDTO(matchSummary.venue); } }
/// <summary> /// Initializes a new instance of the <see cref="CompetitorProfileDTO"/> class /// </summary> /// <param name="record">A <see cref="competitorProfileEndpoint"/> containing information about the profile</param> public CompetitorProfileDTO(competitorProfileEndpoint record) { Contract.Requires(record != null); Contract.Requires(record.competitor != null); Competitor = new CompetitorDTO(record.competitor); if (record.players != null && record.players.Any()) { Players = new ReadOnlyCollection <PlayerProfileDTO>(record.players.Select(p => new PlayerProfileDTO(p)).ToList()); } if (record.jerseys != null) { Jerseys = new ReadOnlyCollection <JerseyDTO>(record.jerseys.Select(p => new JerseyDTO(p)).ToList()); } if (record.manager != null) { Manager = new ManagerDTO(record.manager); } if (record.venue != null) { Venue = new VenueDTO(record.venue); } }