// Add/Update question to questionlist public void AddQuestion() { var item = SelectedQuestion.Index == 0 ? null : SelectedQuestionList.Questions.FirstOrDefault(i => i.Index == SelectedQuestion.Index); if (TypeConverter.type[SelectedQuestion.Type] == "Table") { var temp = new ViewModelLocator().OptionHandlerViewModel; temp.OptionTemp.Insert(0, temp.HeaderOne); temp.OptionTemp.Insert(1, temp.HeaderTwo); SelectedQuestion.QuestionOptions = temp.ListToString(); } if (item == null) { try { SelectedQuestionList.Questions.Add(SelectedQuestion.ToQuestion()); Questions.Add(SelectedQuestion); SelectedQuestion = null; SwitchView = 1; UpdateIndex(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } } else { item = SelectedQuestion.ToQuestion(); var t = Questions.Single(i => i.Index == SelectedQuestion.Index); t = SelectedQuestion; SelectedQuestion = null; SwitchView = 1; UpdateIndex(); } }