Created
July 11, 2011 17:55
-
-
Save danappleyard/1076376 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Function AddQuestionToExistingQuestionPool(ByVal question As QuestionsEntity, ByVal distractors As IList(Of DistractorsEntity), ByVal ts As TimeStamp) As Validation Implements IQuestionService.AddQuestionToExistingQuestionPool | |
Dim val As Validation = _validator.ValidateNewQuestionForExistingQuestionPool(ConvertQuestionToViewModel(question, distractors)) | |
If val.IsValid Then | |
Using trans As Transaction = _transBuilder.BuildTransaction("AddNewQuestion") | |
Try | |
question.Sequence = _questionPoolRepo.GetNextSequenceNumber(question.QuestionPoolID, trans) | |
_questionRepo.Insert(question, ts, trans) | |
For Each d As DistractorsEntity In distractors | |
d.QuestionID = question.QuestionID | |
_distractorRepo.Insert(d, ts, trans) | |
Next | |
_synchronizer.SynchronizeLearningReviewsWithQuestionPool(question.QuestionPoolID, LearningReviewQuestionPoolSynchronizationReason.Question_Added, ts, trans) | |
trans.Commit() | |
Catch ex As ORMQueryExecutionException | |
trans.Rollback() | |
val.AddErrorMessage(String.Format("Error adding new Question: {0}; QUERY:{1}", ex.Message, ex.QueryExecuted)) | |
End Try | |
End Using | |
End If | |
Return val | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment