private async Task InsertUser(User user) { // This code inserts a new User into the database. When the operation completes // and Mobile Services has assigned an Id, the item is added to the CollectionView await usersTable.InsertAsync(user); users.Add(user); //await SyncAsync(); // offline sync }
private async Task RegisterUser() { User user = new User { Id = this.user.UserId }; if (users == null || curr != null) { return; } try { curr = await usersTable.LookupAsync(user.Id); } catch (Exception) { //User does not exist } if (curr != null) { return; } try { await usersTable.InsertAsync(user); } catch (Exception) { // } curr = await usersTable.LookupAsync(this.user.UserId); }
private async Task UpdateCheckedTodoItem(User user) { // This code takes a freshly completed TodoItem and updates the database. When the MobileService // responds, the item is removed from the list await usersTable.UpdateAsync(user); users.Remove(user); ListItems.Focus(Windows.UI.Xaml.FocusState.Unfocused); //await SyncAsync(); // offline sync }
private async void HowdyButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { ((Button)sender).IsEnabled = false; if (curr == null) { curr = await usersTable.LookupAsync(user.UserId); } Howdy send = new Howdy{ From = curr.Name, To = (((Button)sender).DataContext as User).Id}; await howdyTable.InsertAsync(send); ((Button)sender).IsEnabled = true; }