/// <summary> /// Maps the <see cref="tournamentExtended"/> instance to the one of the derived types of <see cref="SportEventSummaryDTO"/> /// </summary> /// <param name="item">The item to be mapped</param> /// <returns>A <see cref="SportEventSummaryDTO"/> derived instance</returns> /// <exception cref="ArgumentException">id</exception> public static SportEventSummaryDTO MapSportEvent(tournamentExtended item) { if (item == null) { return(null); } var id = URN.Parse(item.id); switch (id.TypeGroup) { case ResourceTypeGroup.BASIC_TOURNAMENT: { return(new BasicTournamentDTO(item)); } case ResourceTypeGroup.TOURNAMENT: case ResourceTypeGroup.SEASON: { return(new TournamentInfoDTO(item)); } default: throw new ArgumentException($"ResourceTypeGroup: {id.TypeGroup} is not supported", nameof(id)); } }
/// <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); }
private static void ValidateTournamentExtended(tournamentExtended msg, TournamentDTO dto) { Assert.AreEqual(msg.id, dto.Id.ToString()); Assert.AreEqual(msg.name, dto.Name); Assert.AreEqual(msg.category.id, dto.Category.Id.ToString()); Assert.AreEqual(msg.category.name, dto.Category.Name); Assert.AreEqual(msg.sport.id, dto.Sport.Id.ToString()); Assert.AreEqual(msg.sport.name, dto.Sport.Name); Assert.AreEqual(msg.scheduled, dto.Scheduled); Assert.AreEqual(msg.scheduled_end, dto.ScheduledEnd); Assert.AreEqual(msg.current_season.id, dto.CurrentSeason.Id.ToString()); // TODO: extended properties are lost }
private static DateTime GetExtendedTournamentSchedule(tournamentExtended tournament, bool useStartTime) { if (useStartTime) { return(IsTournamentScheduleSpecified(tournament, true) ? GetTournamentSchedule(tournament, true) : tournament.current_season != null ? tournament.current_season.start_date : tournament.scheduled); } return(IsTournamentScheduleSpecified(tournament, false) ? GetTournamentSchedule(tournament, false) : tournament.current_season != null ? tournament.current_season.end_date : tournament.scheduled_end); }
/// <summary> /// Initializes a new instance of the <see cref="BasicTournamentDTO"/> class. /// </summary> /// <param name="tournament">The <see cref="tournamentExtended"/> used for creating instance</param> internal BasicTournamentDTO(tournamentExtended tournament) : base(new sportEvent { id = tournament.id, name = tournament.name, scheduled = tournament.scheduled, scheduledSpecified = tournament.scheduledSpecified, scheduled_end = tournament.scheduled_end, scheduled_endSpecified = tournament.scheduled_endSpecified, tournament = tournament, type = null }) { Guard.Argument(tournament, nameof(tournament)).NotNull(); //TournamentCoverage = new TournamentCoverageDTO(tournament.season_coverage_info); Category = tournament.category == null ? null : URN.Parse(tournament.category.id); Competitors = tournament.competitors.Select(s => new CompetitorDTO(s)); }
public static tournamentExtended GetTournamentExtended(int id = 0, int subItemCount = 0) { if (subItemCount == 0) { subItemCount = SR.I(20); } var msg = new tournamentExtended { id = id == 0 ? SR.Urn("tournament").ToString() : SR.Urn(id, "tournament").ToString(), name = "Tournament name " + SR.S(1000), scheduled = DateTime.Now, scheduledSpecified = true, scheduled_end = DateTime.Today, scheduled_endSpecified = true, category = GetCategory(), sport = GetSport(), tournament_length = GetTournamentLength(), current_season = GetCurrentSeason(), season_coverage_info = GetSeasonCoverageInfo(), competitors = GetTeamList(subItemCount).ToArray() }; return(msg); }