public async Task <VenueDto> GetVenue(string venueId) { if (string.IsNullOrEmpty(venueId)) { return(null); } return(Mapper.Map <VenueDto>(await VenuesTable.LookupAsync(venueId).ConfigureAwait(false))); }
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"]); } } }
public async Task <List <VenueDto> > GetVenues() { return(Mapper.Map <List <Venue>, List <VenueDto> >(await VenuesTable.ToListAsync().ConfigureAwait(false))); }