コード例 #1
0
        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));
        }
コード例 #2
0
        private async Task UpdateCheckedTodoItem(TodoItem item)
        {
            await todoTable.UpdateAsync(item);

            items.Remove(item);
            ListItems.Focus(Windows.UI.Xaml.FocusState.Unfocused);
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: phaufe/ZumoContrib
        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);
        }
コード例 #4
0
ファイル: MainPage.cs プロジェクト: ilin61/GoGoGoServer
        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);
        }
コード例 #5
0
ファイル: MainPage.cs プロジェクト: jackhwl/azure
        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);
        }
コード例 #6
0
        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
        }
コード例 #7
0
        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
        }
コード例 #8
0
        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();
        }
コード例 #10
0
        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
        }
コード例 #11
0
        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 { }
        }
コード例 #13
0
        /// <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();
        }
コード例 #14
0
        /// <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();
        }
コード例 #15
0
        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));
        }
コード例 #16
0
        private async void UpdateCheckedTodoItem(TodoItem item)
        {
            await todoTable.UpdateAsync(item);

            items.Remove(item);
        }