/// <summary> /// Adds the answer data. /// </summary> /// <param name="answerData">The answer data.</param> /// <param name="recordIdentification">The record identification.</param> public void AddAnswer(Dictionary <string, object> answerData, string recordIdentification) { string answerId; if (this.Question.HasAnswerOptions) { answerId = answerData.ValueOrDefault(Constants.QuestionnaireAnswerNumber) as string; } else { answerId = answerData.ValueOrDefault(Constants.QuestionnaireAnswer) as string; if (this.Question.AnswersFromCatalog && this.Question.Questionnaire.Manager.SaveCatalogValuesAsText) { answerId = this.Question.AnswerIdForText(answerId); if (answerId == null) { return; } } } if (answerId != null) { UPSurveyAnswerSingle singleAnswer = new UPSurveyAnswerSingle(answerId, recordIdentification); this.singleAnswerDictionary[answerId] = singleAnswer; } }
/// <summary> /// Sets the answer array. /// </summary> /// <param name="answers">The answers.</param> public void SetAnswerArray(List <string> answers) { foreach (UPSurveyAnswerSingle singleAnswer in this.singleAnswerDictionary.Values) { if (!singleAnswer.Deleted) { singleAnswer.CheckDelete = true; } } foreach (string currentAnswer in answers) { UPSurveyAnswerSingle singleAnswer = this.singleAnswerDictionary.ValueOrDefault(currentAnswer); if (singleAnswer != null) { if (singleAnswer.Deleted) { singleAnswer.Deleted = false; this.Changed = true; } else { singleAnswer.CheckDelete = false; } } else { this.singleAnswerDictionary[currentAnswer] = new UPSurveyAnswerSingle(currentAnswer); this.Changed = true; } } foreach (UPSurveyAnswerSingle singleAnswer in this.singleAnswerDictionary.Values) { if (singleAnswer.CheckDelete) { singleAnswer.CheckDelete = false; singleAnswer.Deleted = true; this.Changed = true; } } }