/// <summary>
        /// Initializes a new instance of the <see cref="TournamentDTO"/> class.
        /// </summary>
        /// <param name="tournament">The <see cref="tournamentExtended"/> used for creating instance</param>
        internal TournamentDTO(tournamentExtended tournament)
            : base(tournament.id, tournament.name)
        {
            Contract.Requires(tournament != null);

            Scheduled = tournament.scheduledSpecified
                ? (DateTime?)tournament.scheduled
                : null;

            ScheduledEnd = tournament.scheduled_endSpecified
                ? (DateTime?)tournament.scheduled_end
                : null;

            Sport = new SportEntityDTO(tournament.sport.id, tournament.sport.name);

            Category = tournament.category == null && tournament.id.StartsWith("vf")
                ? CreateFakeCategory()
                : new CategorySummaryDTO(tournament.category?.id, tournament.category?.name, tournament.category?.country_code);

            CurrentSeason = tournament.current_season == null
                ? null
                : new SeasonDTO(tournament.current_season);

            SeasonCoverage = tournament.season_coverage_info == null
                ? null
                : new SeasonCoverageDTO(tournament.season_coverage_info);
        }
Пример #2
0
        internal SportCategoriesDTO(sportCategoriesEndpoint categoriesEndpoint)
        {
            Contract.Requires(categoriesEndpoint != null);
            Contract.Requires(categoriesEndpoint.sport != null);

            Sport      = new SportEntityDTO(categoriesEndpoint.sport.id, categoriesEndpoint.sport.name);
            Categories = categoriesEndpoint.categories?.Select(c => new CategoryDTO(c.id, c.name, c.country_code, new List <tournamentExtended>())).ToList();
        }
Пример #3
0
        internal SportCategoriesDTO(sportCategoriesEndpoint categoriesEndpoint)
        {
            Guard.Argument(categoriesEndpoint, nameof(categoriesEndpoint)).NotNull();
            Guard.Argument(categoriesEndpoint.sport, nameof(categoriesEndpoint.sport)).NotNull();

            Sport      = new SportEntityDTO(categoriesEndpoint.sport.id, categoriesEndpoint.sport.name);
            Categories = categoriesEndpoint.categories?.Select(c => new CategoryDTO(c.id, c.name, c.country_code, new List <tournamentExtended>())).ToList();
        }
Пример #4
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 SportEntityDTO(matchSummary.sport_event.season.id, matchSummary.sport_event.season.name);
            }
            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);
            }
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MatchDTO"/> class
        /// </summary>
        /// <param name="sportEvent">A <see cref="sportEvent"/> instance containing basic information about the sport event</param>
        internal MatchDTO(sportEvent sportEvent)
            : base(sportEvent)
        {
            Guard.Argument(sportEvent, nameof(sportEvent)).NotNull();

            if (sportEvent.season != null)
            {
                Guard.Argument(sportEvent.season.id, nameof(sportEvent.season.id)).NotNull().NotEmpty();
                Guard.Argument(sportEvent.season.name, nameof(sportEvent.season.name)).NotNull().NotEmpty();
                Season = new SportEntityDTO(sportEvent.season.id, sportEvent.season.name);
            }
            if (sportEvent.tournament_round != null)
            {
                Round = new RoundDTO(sportEvent.tournament_round);
            }
            if (sportEvent.tournament != null)
            {
                Guard.Argument(sportEvent.tournament.id, nameof(sportEvent.tournament.id)).NotNull().NotEmpty();
                Guard.Argument(sportEvent.tournament.name, nameof(sportEvent.tournament.name)).NotNull().NotEmpty();
                Tournament = new TournamentDTO(sportEvent.tournament);
            }
        }
Пример #6
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)
        {
            Contract.Requires(matchSummary != null);

            if (matchSummary.sport_event.season != null)
            {
                Contract.Assume(!string.IsNullOrEmpty(matchSummary.sport_event.season.id));
                Contract.Assume(!string.IsNullOrEmpty(matchSummary.sport_event.season.name));
                Season = new SportEntityDTO(matchSummary.sport_event.season.id, matchSummary.sport_event.season.name);
            }
            if (matchSummary.sport_event.tournament_round != null)
            {
                Round = new RoundDTO(matchSummary.sport_event.tournament_round);
            }
            if (matchSummary.sport_event.tournament != null)
            {
                Contract.Assume(!string.IsNullOrEmpty(matchSummary.sport_event.tournament.id));
                Contract.Assume(!string.IsNullOrEmpty(matchSummary.sport_event.tournament.name));
                Tournament = new TournamentDTO(matchSummary.sport_event.tournament);
            }
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MatchDTO"/> class
        /// </summary>
        /// <param name="sportEvent">A <see cref="sportEvent"/> instance containing basic information about the sport event</param>
        internal MatchDTO(sportEvent sportEvent)
            : base(sportEvent)
        {
            Contract.Requires(sportEvent != null);

            if (sportEvent.season != null)
            {
                Contract.Assume(!string.IsNullOrEmpty(sportEvent.season.id));
                Contract.Assume(!string.IsNullOrEmpty(sportEvent.season.name));
                Season = new SportEntityDTO(sportEvent.season.id, sportEvent.season.name);
            }
            if (sportEvent.tournament_round != null)
            {
                Round = new RoundDTO(sportEvent.tournament_round);
            }
            if (sportEvent.tournament != null)
            {
                Contract.Assume(!string.IsNullOrEmpty(sportEvent.tournament.id));
                Contract.Assume(!string.IsNullOrEmpty(sportEvent.tournament.name));
                Tournament = new TournamentDTO(sportEvent.tournament);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TournamentDTO"/> class.
        /// </summary>
        /// <param name="tournament">The <see cref="tournament"/> used for creating instance</param>
        internal TournamentDTO(tournament tournament)
            : base(tournament.id, tournament.name)
        {
            Contract.Requires(tournament != null);

            Scheduled = tournament.scheduledSpecified
                ? (DateTime?)tournament.scheduled
                : null;

            ScheduledEnd = tournament.scheduled_endSpecified
                ? (DateTime?)tournament.scheduled_end
                : null;

            Sport = new SportEntityDTO(tournament.sport.id, tournament.sport.name);

            //TODO: check for 'vf': is it still required?
            Category = tournament.category == null && tournament.id.StartsWith("vf")
                ? CreateFakeCategory()
                : new CategorySummaryDTO(tournament.category?.id, tournament.category?.name, tournament.category?.country_code);

            CurrentSeason  = null;
            SeasonCoverage = null;
        }
Пример #9
0
        internal BasicEventDTO(basicEvent item)
        {
            Guard.Argument(item, nameof(item)).NotNull();

            Id           = item.id;
            HomeScore    = item.home_scoreSpecified ? (decimal?)item.home_score : null;
            AwayScore    = item.away_scoreSpecified ? (decimal?)item.away_score : null;
            MatchTime    = item.match_timeSpecified ? (int?)item.match_time : null;
            Period       = item.period;
            PeriodName   = item.period_name;
            Points       = item.points;
            StoppageTime = item.stoppage_time;
            Team         = item.team == null
                ? (HomeAway?)null
                : item.team.Equals("home", StringComparison.InvariantCultureIgnoreCase)
                    ? HomeAway.Home
                    : HomeAway.Away;
            Type  = item.type;
            Value = item.value;
            X     = item.xSpecified ? (int?)item.x : null;
            Y     = item.ySpecified ? (int?)item.y : null;
            Time  = item.time;
            if (item.assist != null && item.assist.Length > 0)
            {
                Assists = item.assist.Select(s => new EventPlayerAssistDTO(s));
            }
            if (item.goal_scorer != null)
            {
                GoalScorer = new SportEntityDTO(item.goal_scorer.id, item.goal_scorer.name);
            }
            if (item.player != null)
            {
                Player = new SportEntityDTO(item.player.id, item.player.name);
            }
            MatchStatusCode = item.match_status_codeSpecified ? (int?)item.match_status_code : null;
            MatchClock      = item.match_clock;
        }