public void MobileServiceCollectionCanRemoveAndNotifies() { // Get the Books table MobileServiceTableQueryMock <Book> query = new MobileServiceTableQueryMock <Book>(); query.EnumerableAsyncThrowsException = true; MobileServiceCollection <Book, Book> collection = new MobileServiceCollection <Book, Book>(query); List <string> properties = new List <string>(); List <string> expectedProperties = new List <string>() { "Count", "Item[]" }; List <NotifyCollectionChangedAction> actions = new List <NotifyCollectionChangedAction>(); List <NotifyCollectionChangedAction> expectedActions = new List <NotifyCollectionChangedAction>() { NotifyCollectionChangedAction.Remove }; Book book = new Book(); collection.Add(book); ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName); collection.CollectionChanged += (s, e) => actions.Add(e.Action); collection.Remove(book); Assert.AreEqual(0, collection.Count); Assert.IsTrue(properties.SequenceEqual(expectedProperties)); Assert.IsTrue(actions.SequenceEqual(expectedActions)); }
private async Task UpdateCheckedTodoItem(TodoItem item) { await todoTable.UpdateAsync(item); items.Remove(item); ListItems.Focus(Windows.UI.Xaml.FocusState.Unfocused); }
private async void UpdateCheckedTodoItem(TodoItem item) { // This code takes a freshly completed TodoItem and updates the database. When the MobileService // responds, the item is removed from the list await todoTable.UpdateAsync(item); items.Remove(item); }
private async Task UpdateCheckedTodoItem(TodoItem item) { // This code takes a freshly completed TodoItem and updates the database. When the MobileService // responds, the item is removed from the list await todoTable.UpdateAsync(item); items.Remove(item); ListItems.Focus(Windows.UI.Xaml.FocusState.Unfocused); }
private async Task UpdateCheckedDemoColorItem(DemoColor item) { // This code removes the DemoColor from the database. When the service // responds, the item is removed from the list. await demoTable.DeleteAsync(item); items.Remove(item); ListItems.Focus(FocusState.Unfocused); }
private async Task DeleteTeam(Team team) { // This code inserts a new Tournament into the database. When the operation completes // and Mobile Apps has assigned an Id, the item is added to the CollectionView await teamsTable.DeleteAsync(team); teams.Remove(team); //await App.MobileService.SyncContext.PushAsync(); // offline sync }
private async Task UpdateCheckedTodoItem(TodoItem item) { await todoTable.UpdateAsync(item); items.Remove(item); //ListItems.Focus(Windows.UI.Xaml.FocusState.Unfocused); #if OFFLINE_SYNC_ENABLED await App.MobileService.SyncContext.PushAsync(); // offline sync #endif }
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 Task UpdateCheckedTodoItem(TodoItem item) { // This code takes a freshly completed TodoItem and updates the database. When the MobileService // responds, the item is removed from the list await todoTable.UpdateAsync(item); items.Remove(item); ListItems.Focus(Windows.UI.Xaml.FocusState.Unfocused); // Upload offline changes to the backend. await App.MobileService.SyncContext.PushAsync(); }
private async Task UpdateCheckedTodoItem(TodoItem item) { // This code takes a freshly completed TodoItem and updates the database. // After the MobileService client responds, the item is removed from the list. await todoTable.UpdateAsync(item); items.Remove(item); ListItems.Focus(Windows.UI.Xaml.FocusState.Unfocused); #if OFFLINE_SYNC_ENABLED await App.MobileService.SyncContext.PushAsync(); // offline sync #endif }
private async Task UpdateCheckedTodoItem(TodoItem item) { // This code takes a freshly completed TodoItem and updates the database. When the service // responds, the item is removed from the list. await todoTable.UpdateAsync(item); items.Remove(item); ListItems.Focus(Windows.UI.Xaml.FocusState.Unfocused); #if OFFLINE_SYNC_ENABLED await SyncAsync(); // offline sync #endif }
private async Task UpdateCheckedTodoItem(ToDoItemDocDb item) { // This code takes a freshly completed TodoItem and updates the database. // After the MobileService client responds, the item is removed from the list. await todoTable.UpdateAsync(item); todoItems.Remove(item); ListItems.Focus(Windows.UI.Xaml.FocusState.Unfocused); try { await App.MobileService.SyncContext.PushAsync(); } catch { } }
/// <summary> /// Event Handler: Delete a record /// </summary> private async void nameField_Delete(object sender, TappedRoutedEventArgs e) { SymbolIcon icon = (SymbolIcon)sender; Friend item = icon.DataContext as Friend; StartNetworkActivity(); try { await dataTable.DeleteAsync(item); friends.Remove(item); } catch (MobileServiceInvalidOperationException exception) { var dialog = new MessageDialog(exception.Message); await dialog.ShowAsync(); } StopNetworkActivity(); }
/// <summary> /// Event Handler: Delete a record /// </summary> private async void taskDelete_Tapped(object sender, TappedRoutedEventArgs e) { Trace("taskDelete_tapped"); SymbolIcon icon = (SymbolIcon)sender; TodoItem item = icon.DataContext as TodoItem; StartNetworkActivity(); try { Trace($"Deleting task id={item.Id} title={item.Title} completed={item.Completed}"); await dataTable.DeleteAsync(item); tasks.Remove(item); } catch (MobileServiceInvalidOperationException exception) { Trace($"taskDelete_Tapped - failed to delete title ID={item.Id} Error={exception.Message}"); var dialog = new MessageDialog(exception.Message); await dialog.ShowAsync(); } StopNetworkActivity(); }
public void MobileServiceCollectionCanRemoveAndNotifies() { // Get the Books table MobileServiceTableQueryMock<Book> query = new MobileServiceTableQueryMock<Book>(); query.EnumerableAsyncThrowsException = true; MobileServiceCollection<Book, Book> collection = new MobileServiceCollection<Book, Book>(query); List<string> properties = new List<string>(); List<string> expectedProperties = new List<string>() { "Count", "Item[]" }; List<NotifyCollectionChangedAction> actions = new List<NotifyCollectionChangedAction>(); List<NotifyCollectionChangedAction> expectedActions = new List<NotifyCollectionChangedAction>() { NotifyCollectionChangedAction.Remove }; Book book = new Book(); collection.Add(book); ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName); collection.CollectionChanged += (s, e) => actions.Add(e.Action); collection.Remove(book); Assert.AreEqual(0, collection.Count); Assert.IsTrue(properties.SequenceEqual(expectedProperties)); Assert.IsTrue(actions.SequenceEqual(expectedActions)); }
private async void UpdateCheckedTodoItem(TodoItem item) { await todoTable.UpdateAsync(item); items.Remove(item); }