private async Task Load(bool forced) { try { IList <Game> games = new List <Game>(); if (forced) { IsBusy = true; var results = await CardboardKnight.GetTop100().ConfigureAwait(false); foreach (var g in results) { games.Add(await CardboardKnight.StoreGame(g).ConfigureAwait(false)); } } else { var r = await CardboardKnight.RetrieveGames(); var g = r.FirstOrDefault(); //This is a *really* ugly query games = r.Where(g => g.Ranks.Any(rank => rank.Category == Category.All && rank.Position >= 1 && rank.Position <= 100)) .OrderBy(g => g.Ranks.FirstOrDefault(rank => rank.Category == Category.All).Position) .ToList(); if (games.Count < 100) { await Load(true); return; } } Top100 = new MvxObservableCollection <Game>(games); } catch (Exception ex) { //TODO: some sort of logging } finally { IsBusy = false; } }
private async Task <List <Game> > Load(bool forced) { List <Game> games = new List <Game>(); try { if (forced) { var results = await CardboardKnight.GetTop100(category : Category); foreach (var g in results) { games.Add(await CardboardKnight.StoreGame((Game)g)); } } else { // This now has issues with multiple-top - 100 lists, and wouldn't allow for paging. // For now, just fetch the list every time, no caching. //var r = await CardboardKnight.RetrieveGames(); //games = r // .Where(g => g.Rank >= 1 && g.Rank <= 100) // .OrderBy(g => g.Rank) // .ToList(); //if (games.Count < 100) //{ return(await Load(true)); //} } Games = new ObservableCollection <Game>(games); } catch (Exception ex) { //Debug.WriteLine(ex); } return(games); }