private async Task InsertTodoItem(TodoItem todoItem) { // This code inserts a new TodoItem into the database. When the operation completes // and Mobile Services has assigned an Id, the item is added to the CollectionView await todoTable.InsertAsync(todoItem); items.Add(todoItem); }
private async Task<IUICommand> ShowConflictDialog(TodoItem localItem, JObject serverValue) { var dialog = new MessageDialog( "How do you want to resolve this conflict?\n\n" + "Local item: \n" + localItem + "\n\nServer item:\n" + serverValue.ToObject<TodoItem>(), title: "Conflict between local and server versions"); dialog.Commands.Add(new UICommand(LOCAL_VERSION)); dialog.Commands.Add(new UICommand(SERVER_VERSION)); // Windows Phone not supporting 3 command MessageDialog //dialog.Commands.Add(new UICommand("Cancel")); return await dialog.ShowAsync(); }
private async void ButtonSave_Click(object sender, RoutedEventArgs e) { var todoItem = new TodoItem { Text = TextInput.Text }; TextInput.Text = ""; await InsertTodoItem(todoItem); }
private async void ButtonDelte_Click(object sender, RoutedEventArgs e) { var tb = (Button)sender; var item = tb.DataContext as TodoItem; lastDeleted = item; await todoTable.DeleteAsync(item); await RefreshTodoItems(); }
private async Task UpdateTodoItem(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); }