void doneButton_Click(object sender, EventArgs e) { TodoistService todoistService = new TodoistService(); var commandTimeGenerated = DateTime.Now; Item Task = new Item { content = ContentTextBox.Text, date_string = DateStringTextBox.Text, project_id = projectSelected.id }; doneButton.IsEnabled = false; todoistService.AddTaskToProject(commandTimeGenerated, Task, (data) => { todoistService.GetData( (fullData) => { app.projects = fullData.Projects; app.notes = fullData.Notes; app.items = fullData.Items; var tempID = Utils.DateTimeToUnixTimestamp(commandTimeGenerated).ToString(); Task.id = data.TempIdMapping[tempID]; Task = app.items.Where(x => x.id == Task.id).FirstOrDefault(); MainTodoistPage.updateProjectList(fullData.Projects); ProjectDetail.showMessage = (progress) => { Utils.ProgressIndicatorStatus(String.Format("\"{0}\" added.", Task.content), progress); ProjectDetail.showMessage = null; }; }, (errorMessage) => { }, () => { doneButton.IsEnabled = true; var currentPage = app.RootFrame.Content as PhoneApplicationPage; if (currentPage == this) NavigationService.GoBack(); }); }, (errorMsg) => { MessageBox.Show(Utils.Message(errorMsg), "Metroist", MessageBoxButton.OK); }); //NavigationService.GoBack(); }