private async Task DeleteItem (TaskItem task) { var confirmed = await UserDialogs.Instance.ConfirmAsync ( string.Format ("Are you sure you want to delete '{0}'?", task.Name), "Delete Task", "Yes", "No"); if (confirmed) { using (UserDialogs.Instance.Loading ("Deleting task...")) { // update DB await db.DeleteAsync (task); // update UI var tasks = (ObservableCollection<TaskItem>)listView.ItemsSource; tasks.Remove (task); } } }
private async Task EditItem (TaskItem task) { if (task == null) { task = new TaskItem (); } // get a new name var result = await UserDialogs.Instance.PromptAsync ( "Enter the name of the task:", "Task", "Add", "Cancel", "Task name"); if (result.Ok) { var name = result.Text.Trim (); if (string.IsNullOrEmpty (name)) { // there was no name provided await UserDialogs.Instance.AlertAsync ( "The task must have a name.", "Task"); } else { // start adding tasks task.Name = name; using (UserDialogs.Instance.Loading ("Saving task...")) { // update DB if (task.Id == 0) { await db.InsertAsync (task); } else { await db.UpdateAsync (task); } // update UI await RefreshList (); } } } }
private async Task CompleteItem (TaskItem task) { task.Completed = !task.Completed; using (UserDialogs.Instance.Loading ("Saving task...")) { // update DB await db.UpdateAsync (task); // update UI await RefreshList (); } }