public async Task SyncAsync() { if (!IsOnline) { return; } ReadOnlyCollection <MobileServiceTableOperationError> syncErrors = null; try { await App.MobileService.SyncContext.PushAsync().ConfigureAwait(false); await GamesTable.PullAsync("AllGames", this.GamesTable.CreateQuery()).ConfigureAwait(false); await PlayersTable.PullAsync("AllPlayers", this.PlayersTable.CreateQuery()).ConfigureAwait(false); await VenuesTable.PullAsync("AllVenues", this.PlayersTable.CreateQuery()).ConfigureAwait(false); await GamePlayersTable.PullAsync("AllGamePlayers", this.GamePlayersTable.CreateQuery()).ConfigureAwait(false); await TeesTable.PullAsync("AllTees", this.TeesTable.CreateQuery()).ConfigureAwait(false); await ScoresTable.PullAsync("AllScores", this.ScoresTable.CreateQuery()).ConfigureAwait(false); } catch (MobileServicePushFailedException exc) { if (exc.PushResult != null) { syncErrors = exc.PushResult.Errors; } } // Simple error/conflict handling. if (syncErrors != null) { foreach (var error in syncErrors) { if (error.OperationKind == MobileServiceTableOperationKind.Update && error.Result != null) { //Update failed, reverting to server's copy. await error.CancelAndUpdateItemAsync(error.Result).ConfigureAwait(false); } else { // Discard local change. await error.CancelAndDiscardItemAsync().ConfigureAwait(false); } Debug.WriteLine(@"Error executing sync operation. Item: {0} ({1}). Operation discarded.", error.TableName, error.Item["id"]); } } }
private void createScoreTable(RulesetInfo ruleset, int page = 1) { onLoadStarted(); request = new GetUserRankingsRequest(ruleset, UserRankingsType.Score, page); ((GetUserRankingsRequest)request).Success += rankings => Schedule(() => { var table = new ScoresTable(page, rankings.Users); loadTable(table); }); api.Queue(request); }
private void createSpotlightTable(RulesetInfo ruleset, int spotlight) { onLoadStarted(); request = new GetSpotlightRankingsRequest(ruleset, spotlight, RankingsSortCriteria.All); ((GetSpotlightRankingsRequest)request).Success += rankings => Schedule(() => { var table = new ScoresTable(1, rankings.Users); loadTable(table); }); api.Queue(request); }
public async Task <PlayGameDto> GetPlayGame(string gameId) { var result = new PlayGameDto { Game = await GamesTable.LookupAsync(gameId).ConfigureAwait(false), Players = (await GetPlayersForGame(gameId).ConfigureAwait(false)).OrderBy(x => x.Abbreviation).ToList(), Tees = Mapper.Map <List <Tee>, List <TeeDto> >(await TeesTable.Where(x => x.GameId == gameId).OrderBy(x => x.Number).ToListAsync().ConfigureAwait(false)), Scores = Mapper.Map <List <Score>, List <ScoreDto> >(await ScoresTable.Where(x => x.GameId == gameId).ToListAsync().ConfigureAwait(false)), }; result.Venue = await GetVenue(result.Game.VenueId).ConfigureAwait(false); return(result); }