/// <summary> /// Saves or updates the the specified question item based on the CurrentUIMode /// </summary> /// <param name="QuestionItem">The question item.</param> /// <returns>Task.</returns> async internal Task Save(QuestionItem questionItem) { if (CurrentUIMode == UIModes.Adding) { await AddQuestion(questionItem); } else if (CurrentUIMode == UIModes.Editing) { await UpdateQuestion(questionItem); } }
/// <summary> /// Interface to delete the question. /// </summary> /// <param name="questionItem">Question item.</param> public async void DeleteQuestion(QuestionItem questionItem) { try { Task deleteQuestion = theQuestionInfo.DeleteQuestion(questionItem); await UIUtilities.ShowIndeterminateProgressIfNecessary(deleteQuestion, string.Format("Deleting task: [{0}] ...", questionItem.QuestionText)); } finally { NavigationController.PopViewControllerAnimated(true); } }
/// <summary> /// Interface to create the question. /// </summary> /// <param name="sender">Sender.</param> /// <param name="args">Arguments.</param> public void CreateQuestion(object sender, EventArgs args) { // first, add the question to the underlying data var newQuestionItem = new QuestionItem(); theQuestionInfo.CurrentUIMode = UIModes.Adding; // then open the detail view to edit it var detail = Storyboard.InstantiateViewController("QuestionDetailViewController") as QuestionDetailViewController; detail.SetQuestion(this, newQuestionItem); NavigationController.PushViewController(detail, true); }
/// <summary> /// Interface to save the question. /// </summary> /// <param name="questionItem">Question item.</param> public async void SaveQuestion(QuestionItem questionItem) { try { Task saveTask = theQuestionInfo.Save(questionItem); if (theQuestionInfo.CurrentUIMode == UIModes.Adding) { await UIUtilities.ShowIndeterminateProgressIfNecessary(saveTask, string.Format("Adding task: [{0}] ...", questionItem.QuestionText)); } else { await UIUtilities.ShowIndeterminateProgressIfNecessary(saveTask, string.Format("Updating task: [{0}] ...", questionItem.QuestionText)); } await RefreshAsync(); } finally { NavigationController.PopViewControllerAnimated(true); } }
/// <summary> /// Sets the question and delegate, used externally. /// </summary> /// <param name="d">D.</param> /// <param name="question">Question.</param> public void SetQuestion(MasterViewController d, QuestionItem question) { Delegate = d; currentQuestion = question; }
/// <summary> /// Updates the question /// </summary> /// <returns>Task.</returns> async internal Task UpdateQuestion(QuestionItem questionItem) { await _questionItemTable.UpdateAsync(questionItem); }
/// <summary> /// Adds the question /// </summary> /// <returns>Task.</returns> async internal Task AddQuestion(QuestionItem questionItem) { await _questionItemTable.InsertAsync(questionItem); }
/// <summary> /// Deletes the question then refreshes the question list /// </summary> async internal Task DeleteQuestion(QuestionItem questionItem) { await _questionItemTable.DeleteAsync(questionItem); await RefreshQuestions(); }