private static void ParseMatchTypeFilter(NameValueCollection queryString, MatchFilter filter) { filter.IncludeMatches = true; filter.IncludeTournaments = false; filter.IncludeTournamentMatches = false; if (int.TryParse(queryString["type"], out var matchTypeId) && (matchTypeId < 6)) { if (matchTypeId == 1) { filter.IncludeMatches = false; filter.IncludeTournaments = true; filter.IncludeTournamentMatches = false; } else { var matchTypeFilter = (MatchType)(matchTypeId > 2 ? matchTypeId - 2 : 0); filter.MatchTypes.Add(matchTypeFilter); } } }
public MatchFilter ParseQueryString(MatchFilter filter, NameValueCollection queryString) { if (filter == null) { throw new ArgumentNullException(nameof(filter)); } if (queryString == null) { throw new ArgumentNullException(nameof(queryString)); } var updatedFilter = filter.Clone(); updatedFilter.Query = queryString["q"]?.Trim(); var(fromDate, untilDate) = ParseDateFilter(updatedFilter.FromDate, updatedFilter.UntilDate, queryString); updatedFilter.FromDate = fromDate; updatedFilter.UntilDate = untilDate; return(updatedFilter); }
public string MatchesAndTournaments(MatchFilter filter) { if (filter == null) { return(string.Empty); } if (filter.IncludeMatches && !filter.IncludeTournaments) { return("Matches"); } else if (filter.IncludeMatches && filter.IncludeTournaments) { return("Matches and tournaments"); } else if (filter.IncludeTournaments) { return("Tournaments"); } return(string.Empty); }
private static void ParseMatchResultTypeFilter(NameValueCollection queryString, MatchFilter filter) { if (queryString["format"] == "tweet") { filter.MatchResultTypes.Add(null); } }