/// <summary> /// Initializes a new instance of the <see cref="TournamentDTO"/> class /// </summary> /// <param name="season">A <see cref="SeasonDTO"/> containing basic tournament info</param> internal TournamentInfoDTO(SeasonDTO season) : base(new sportEvent { id = season.Id.ToString(), name = season.Name, scheduledSpecified = true, scheduled = season.StartDate, scheduled_endSpecified = true, scheduled_end = season.EndDate }) { TournamentCoverage = null; Category = null; Sport = null; Competitors = null; CurrentSeason = null; Season = null; SeasonCoverage = null; Groups = null; Schedule = null; CurrentRound = null; Year = season.Year; TournamentInfo = null; //TODO: missing year, tournamentInfo }
/// <summary> /// Initializes a new instance of the <see cref="TournamentInfo"/> class /// </summary> /// <param name="tournament">A <see cref="TournamentInfoDTO"/> containing basic tournament info</param> /// <param name="overwriteSeason">Overwrite tournament base data with season info</param> /// <param name="overwriteCurrentSeason">Overwrite tournament base data with current season info</param> internal TournamentInfoDTO(TournamentInfoDTO tournament, bool overwriteSeason, bool overwriteCurrentSeason) : base(new sportEvent { id = overwriteSeason ? tournament.Season.Id.ToString() : overwriteCurrentSeason ? tournament.CurrentSeason.Id.ToString() : tournament.Id.ToString(), name = overwriteSeason ? tournament.Season.Name : overwriteCurrentSeason ? tournament.CurrentSeason.Name : tournament.Name, scheduledSpecified = overwriteSeason ? tournament.Season.StartDate > DateTime.MinValue : overwriteCurrentSeason ? tournament.CurrentSeason.StartDate > DateTime.MinValue : tournament.Scheduled != null, scheduled = overwriteSeason ? tournament.Season.StartDate : overwriteCurrentSeason ? tournament.CurrentSeason.StartDate : tournament.Scheduled.GetValueOrDefault(DateTime.MinValue), scheduled_endSpecified = overwriteSeason ? tournament.Season.EndDate > DateTime.MinValue : overwriteCurrentSeason ? tournament.CurrentSeason.EndDate > DateTime.MinValue : tournament.ScheduledEnd != null, scheduled_end = overwriteSeason ? tournament.Season.EndDate : overwriteCurrentSeason ? tournament.CurrentSeason.EndDate : tournament.ScheduledEnd.GetValueOrDefault(DateTime.MinValue), tournament = new tournament { id = tournament.Id.ToString(), sport = new sport { id = tournament.Sport.Id.ToString(), name = tournament.Sport.Name } }, status = tournament.StatusOnEvent }) { TournamentCoverage = tournament.TournamentCoverage; Category = tournament.Category; Sport = tournament.Sport; Competitors = tournament.Competitors; CurrentSeason = tournament.CurrentSeason; Season = tournament.Season; SeasonCoverage = tournament.SeasonCoverage; Groups = tournament.Groups; Schedule = tournament.Schedule; CurrentRound = tournament.CurrentRound; Year = overwriteSeason ? tournament.Season.Year : overwriteCurrentSeason ? tournament.CurrentSeason.Year : tournament.Year; TournamentInfo = tournament.TournamentInfo; GeneratedAt = tournament.GeneratedAt; ExhibitionGames = tournament.ExhibitionGames; }
/// <summary> /// Initializes a new instance of the <see cref="TournamentInfoDTO"/> class /// </summary> /// <param name="tournament">A <see cref="tournament"/> containing detailed tournament info</param> internal TournamentInfoDTO(tournamentInfoEndpoint tournament) : base(new sportEvent { id = tournament.tournament.id, name = tournament.tournament.name, scheduledSpecified = IsTournamentScheduleSpecified(tournament.tournament, true) || tournament.tournament.current_season != null, scheduled = GetExtendedTournamentSchedule(tournament.tournament, true), scheduled_endSpecified = IsTournamentScheduleSpecified(tournament.tournament, false) || tournament.tournament.current_season != null, scheduled_end = GetExtendedTournamentSchedule(tournament.tournament, false), tournament = tournament.tournament }) { TournamentCoverage = tournament.coverage_info == null ? null : new TournamentCoverageDTO(tournament.coverage_info); Category = tournament.tournament.category == null ? null : new CategorySummaryDTO(tournament.tournament.category); Sport = tournament.tournament.sport == null ? null : new SportEntityDTO(tournament.tournament.sport.id, tournament.tournament.sport.name); Competitors = tournament.competitors != null ? new ReadOnlyCollection <CompetitorDTO>(tournament.competitors.Select(c => new CompetitorDTO(c)).ToList()) : tournament.tournament?.competitors == null // used for stage events ? null : new ReadOnlyCollection <CompetitorDTO>(tournament.tournament.competitors.Select(c => new CompetitorDTO(c)).ToList()); CurrentSeason = tournament.tournament.current_season == null ? null : new CurrentSeasonInfoDTO(tournament.tournament.current_season); Season = tournament.season == null ? null : new CurrentSeasonInfoDTO(tournament.season); SeasonCoverage = tournament.season_coverage_info == null ? null : new SeasonCoverageDTO(tournament.season_coverage_info); Groups = tournament.groups == null ? null : new ReadOnlyCollection <GroupDTO>(tournament.groups.Select(g => new GroupDTO(g)).ToList()); Schedule = null; CurrentRound = tournament.round == null ? null : new RoundDTO(tournament.round); Year = tournament.tournament?.current_season == null ? tournament.season?.year : tournament.tournament.current_season.year; TournamentInfo = null; if (tournament.tournament?.category != null) { var sportEvent = new sportEvent { id = tournament.tournament.id, name = tournament.tournament.name, scheduledSpecified = IsTournamentScheduleSpecified(tournament.tournament, true) || tournament.tournament.current_season != null, scheduled = GetExtendedTournamentSchedule(tournament.tournament, true), scheduled_endSpecified = IsTournamentScheduleSpecified(tournament.tournament, false) || tournament.tournament.current_season != null, scheduled_end = GetExtendedTournamentSchedule(tournament.tournament, false), tournament = tournament.tournament }; TournamentInfo = new TournamentInfoDTO(sportEvent) { Category = new CategorySummaryDTO(tournament.tournament.category.id, tournament.tournament.category.name, tournament.tournament.category.country_code), CurrentSeason = tournament.tournament.current_season == null ? null : new CurrentSeasonInfoDTO(tournament.tournament.current_season) }; } GeneratedAt = tournament.generated_atSpecified ? tournament.generated_at : (DateTime?)null; ExhibitionGames = tournament.tournament.exhibition_gamesSpecified ? tournament.tournament.exhibition_games : (bool?)null; }