Exemple #1
0
        /// <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="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;
            }
        }