/// <summary> /// A helping method that collects all active tournaments for a /// specific player or LeagueOwner /// </summary> /// <param name="user">A specific user</param> /// <returns>Returns a list of tournaments</returns> private async Task <List <Tournament> > GetActiveTournaments(User user = null) { List <Tournament> newList = new List <Tournament>(); string uri; if (user == null) { uri = "/Tournament/GetActiveTournaments/"; } else { uri = $"/Tournament/GetActiveTournaments/?Leagueid={user.UserId}"; } try { var response = await _APIhelper.GetTournamentAsync(uri); if (response.GetType() == typeof(List <Tournament>)) { newList = response as List <Tournament>; } } catch (Exception) { return(newList); } return(newList); }
private async Task <List <Tournament> > GetActiveTournaments(League league = null) { List <Tournament> newList = new List <Tournament>(); try { string uri = "/Tournament/GetActiveTournaments/"; var response = await _ApiHelper.GetTournamentAsync(uri); if (response.GetType() == typeof(List <Tournament>)) { newList = response as List <Tournament>; } if (newList.Count > 5) { newList.RemoveRange(0, newList.Count - 5); } newList.Reverse(); return(newList); } catch (Exception) { return(newList); } }