public Response CreateResponse(int responseHeaderId, int userId) { var response = new Response { ResponseHeaderId = responseHeaderId, CreatedBy = userId, RevisingUser = userId, CreationDate = DateTime.Now, RevisionDate = DateTime.Now }; this.Context.Responses.InsertOnSubmit(response); return response; }
/// <summary> /// Writes the response entry. /// </summary> /// <param name="responseHeaderId">The response header id.</param> /// <param name="section">The section.</param> /// <param name="question">The question.</param> /// <param name="answer">The answer.</param> /// <param name="responseText">The response text.</param> private void WriteResponseEntry(int responseHeaderId, ISection section, IQuestion question, IAnswer answer, string responseText) { var surveyRepository = new SurveyRepository(); var response = surveyRepository.CreateResponse(responseHeaderId, 1); response.SurveyId = this.SurveyId; response.SurveyText = this.Text; response.ShowSurveyText = this.ShowText; response.TitleOption = this.TitleOption; response.SectionText = section.Text; response.SectionRelativeOrder = section.RelativeOrder; response.ShowSectionText = false; response.SectionId = section.SectionId; response.SectionRelativeOrder = section.RelativeOrder; response.SectionFormatOption = this.SectionFormatOption; response.QuestionId = question.QuestionId; response.QuestionText = question.Text; response.QuestionRelativeOrder = question.RelativeOrder; response.QuestionFormatOption = this.QuestionFormatOption; response.ControlType = question.ControlType; if (answer != null) { response.AnswerId = answer.AnswerId; response.AnswerText = answer.Text; response.AnswerRelativeOrder = answer.RelativeOrder; response.AnswerIsCorrect = answer.IsCorrect; } response.UserResponse = responseText; surveyRepository.SubmitChanges(); Debug.WriteLine(response.ResponseId); }