public FubuContinuation Post(QuizTakeInputModel input) { var quiz = _quizService.GetById(input.QuizId); var take = _quizTakeFactory.GetOrCreate(input.TakeId, input.QuizId, _securityContext.CurrentUser.Identity.Name); var answer = new Answer(input.Question, quiz.IsAnswer(input.Question, input.SelectedAlternative), input.SelectedAlternative); take.UpdateAnswer(answer); if (quiz.Questions.Any(x => x.QuestionNumber == input.Question + 1)) { return FubuContinuation.RedirectTo(input.Next, "GET"); } _quizTakeService.Save(take); return FubuContinuation.RedirectTo(new QuizTakeResultsInputModel { QuizId = input.QuizId, TakeId = input.TakeId }); }
public void UpdateAnswer(Answer answer) { lock (Answers) { if (Answers.Contains(answer)) { Answers.Remove(answer); } Answers.Add(answer); } }