public static QuestionResponse AddResponse(QuestionResponse response) { using (QuizBuilderDb db = new QuizBuilderDb()) { QuestionResponse toAdd = response; db.QuestionResponses.Add(toAdd); db.SaveChanges(); return toAdd; } }
public static QuestionResponse UpdateResponse(QuestionResponse updatedResponse) { using (QuizBuilderDb db = new QuizBuilderDb()) { QuestionResponse currentReponse = db.QuestionResponses.Find(updatedResponse.QuestionResponseID); if (currentReponse != null) { currentReponse.QuestionOptionID = updatedResponse.QuestionOptionID; currentReponse.QuestionID = updatedResponse.QuestionID; currentReponse.IsCorrect = updatedResponse.IsCorrect; currentReponse.UserReviewFlag = updatedResponse.UserReviewFlag; currentReponse.QuizAttemptID = updatedResponse.QuizAttemptID; db.SaveChanges(); return currentReponse; } else { return currentReponse; } } }