public async Task InsertTodoItemAsync (ToDoItem todoItem) { try { // 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); } catch (MobileServiceInvalidOperationException e) { Console.Error.WriteLine (@"ERROR {0}", e.Message); } }
public async Task InsertTodoItemAsync (ToDoItem todoItem) { try { await todoTable.InsertAsync (todoItem); // Insert a new TodoItem into the local database. await SyncAsync(); // send changes to the mobile service Items.Add (todoItem); } catch (MobileServiceInvalidOperationException e) { Console.Error.WriteLine (@"ERROR {0}", e.Message); } }
public async Task CompleteItemAsync (ToDoItem item) { try { // This code takes a freshly completed TodoItem and updates the database. When the MobileService // responds, the item is removed from the list item.Complete = true; await todoTable.UpdateAsync (item); Items.Remove (item); } catch (MobileServiceInvalidOperationException e) { Console.Error.WriteLine (@"ERROR {0}", e.Message); } }
public async void AddItem(View view) { if (client == null || string.IsNullOrWhiteSpace(textNewToDo.Text)) { return; } // Create a new item var item = new ToDoItem { Text = textNewToDo.Text, Complete = false }; try { // Insert the new item into the local store. await todoTable.InsertAsync(item); #if OFFLINE_SYNC_ENABLED // Send changes to the mobile app backend. await SyncAsync(); #endif if (!item.Complete) { adapter.Add(item); } } catch (Exception e) { CreateAndShowDialog(e, "Error"); } textNewToDo.Text = ""; }
async partial void OnAdd (NSObject sender) { if (string.IsNullOrWhiteSpace (itemText.Text)) return; var newItem = new ToDoItem { Text = itemText.Text, Complete = false }; await todoService.InsertTodoItemAsync (newItem); var index = todoService.Items.FindIndex (item => item.Id == newItem.Id); TableView.InsertRows (new [] { NSIndexPath.FromItemSection (index, 0) }, UITableViewRowAnimation.Top); itemText.Text = ""; }
public async void AddItem(View view) { if (client == null || string.IsNullOrWhiteSpace(textNewToDo.Text)) { return; } // Create a new item var item = new ToDoItem { Text = textNewToDo.Text, Complete = false }; try { await toDoTable.InsertAsync(item); // insert the new item into the local database await SyncAsync(); // send changes to the mobile service if (!item.Complete) { adapter.Add(item); } } catch (Exception e) { CreateAndShowDialog(e, "Error"); } textNewToDo.Text = ""; }
public async Task CheckItem(ToDoItem item) { if (client == null) { return; } // Set the item as completed and update it in the table item.Complete = true; try { await toDoTable.UpdateAsync(item); // update the new item in the local database await SyncAsync(); // send changes to the mobile service if (item.Complete) adapter.Remove(item); } catch (Exception e) { CreateAndShowDialog(e, "Error"); } }
public async Task CompleteItemAsync (ToDoItem item) { try { item.Complete = true; await todoTable.UpdateAsync (item); // update todo item in the local database await SyncAsync(); // send changes to the mobile service Items.Remove (item); } catch (MobileServiceInvalidOperationException e) { Console.Error.WriteLine (@"ERROR {0}", e.Message); } }
public ToDoItemWrapper(ToDoItem item) { ToDoItem = item; }
public async void AddItem (View view) { if (client == null || string.IsNullOrWhiteSpace (textNewToDo.Text)) { return; } // Create a new item var item = new ToDoItem { Text = textNewToDo.Text, Complete = false }; try { // Insert the new item await toDoTable.InsertAsync (item); if (!item.Complete) { adapter.Add (item); } } catch (Exception e) { CreateAndShowDialog (e, "Error"); } textNewToDo.Text = ""; }
public async Task CheckItem (ToDoItem item) { if (client == null) { return; } // Set the item as completed and update it in the table item.Complete = true; try { await toDoTable.UpdateAsync (item); if (item.Complete) adapter.Remove (item); } catch (Exception e) { CreateAndShowDialog (e, "Error"); } }
public ToDoItemWrapper (ToDoItem item) { ToDoItem = item; }