コード例 #1
0
        public void ContactSurvey(int submittedSurveyID)
        {
            using (var context = new FSOSSContext())
            {
                try
                {
                    SubmittedSurvey ss = context.SubmittedSurveys.Find(submittedSurveyID);
                    ss.contacted = true;

                    context.Entry(ss).Property(y => y.contacted).IsModified = true;
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    throw new Exception("Please contact the Administrator with the error message: " + e.Message);
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// This method returns if the participants submitted survey indicates if they want to be contacted or not.
 /// </summary>
 /// <param name="submittedSurveyID">the submitted survey id of the survey which we want to know if they want contact</param>
 /// <returns>true, wants contact. false, no contact wanted/needed</returns>
 public bool RequestsContact(int submittedSurveyID)
 {
     using (var context = new FSOSSContext())
     {
         try
         {
             SubmittedSurvey ss = context.SubmittedSurveys.Find(submittedSurveyID);
             if (ss.contacted == false && ss.contact_request == true) // if the submitted survey has a contact request and it has not been resolved, return true
             {
                 return(true);
             }
             else // else, return false
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             throw new Exception("Please contact the Administrator with the error message: " + e.Message);
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// This is the method used when submitting a survey into the database in both the SubmittedSurvey and ParticipantResponse tables
        /// </summary>
        /// <param name="survey_version_id_param"></param>
        /// <param name="unit_id_param"></param>
        /// <param name="meal_id_param"></param>
        /// <param name="participant_type_id_param"></param>
        /// <param name="age_range_id_param"></param>
        /// <param name="gender_id_param"></param>
        /// <param name="contact_request_param"></param>
        /// <param name="contact_room_number_param"></param>
        /// <param name="contact_phone_number_param"></param>
        /// <param name="Q1AResponse_param"></param>
        /// <param name="Q1BResponse_param"></param>
        /// <param name="Q1CResponse_param"></param>
        /// <param name="Q1DResponse_param"></param>
        /// <param name="Q1EResponse_param"></param>
        /// <param name="Q2Response_param"></param>
        /// <param name="Q3Response_param"></param>
        /// <param name="Q4Response_param"></param>
        /// <param name="Q5Response_param"></param>
        public void SubmitSurvey(int survey_version_id_param, int unit_id_param, int meal_id_param, int participant_type_id_param, int age_range_id_param,
                                 int gender_id_param, bool contact_request_param, string contact_room_number_param, string contact_phone_number_param, string Q1AResponse_param,
                                 string Q1BResponse_param, string Q1CResponse_param, string Q1DResponse_param, string Q1EResponse_param, string Q2Response_param, string Q3Response_param,
                                 string Q4Response_param, string Q5Response_param)
        {
            using (var context = new FSOSSContext())
            {
                SubmittedSurvey newSurvey = new SubmittedSurvey();
                newSurvey.survey_version_id    = survey_version_id_param;
                newSurvey.date_entered         = DateTime.Now;
                newSurvey.unit_id              = unit_id_param;
                newSurvey.meal_id              = meal_id_param;
                newSurvey.participant_type_id  = participant_type_id_param;
                newSurvey.age_range_id         = age_range_id_param;
                newSurvey.gender_id            = gender_id_param;
                newSurvey.contact_request      = contact_request_param;
                newSurvey.contact_room_number  = contact_room_number_param;
                newSurvey.contact_phone_number = contact_phone_number_param;
                context.SubmittedSurveys.Add(newSurvey);
                context.SaveChanges();

                var newSurveyId = (from x in context.SubmittedSurveys
                                   select x.submitted_survey_id).Max();

                ParticipantResponse q1AResponse = new ParticipantResponse();
                q1AResponse.submitted_survey_id = newSurveyId;
                q1AResponse.question_id         = 2;
                q1AResponse.participant_answer  = Q1AResponse_param;
                context.ParticipantResponses.Add(q1AResponse);
                context.SaveChanges();

                ParticipantResponse q1BResponse = new ParticipantResponse();
                q1BResponse.submitted_survey_id = newSurveyId;
                q1BResponse.question_id         = 3;
                q1BResponse.participant_answer  = Q1BResponse_param;
                context.ParticipantResponses.Add(q1BResponse);
                context.SaveChanges();

                ParticipantResponse q1CResponse = new ParticipantResponse();
                q1CResponse.submitted_survey_id = newSurveyId;
                q1CResponse.question_id         = 4;
                q1CResponse.participant_answer  = Q1CResponse_param;
                context.ParticipantResponses.Add(q1CResponse);
                context.SaveChanges();

                ParticipantResponse q1DResponse = new ParticipantResponse();
                q1DResponse.submitted_survey_id = newSurveyId;
                q1DResponse.question_id         = 5;
                q1DResponse.participant_answer  = Q1DResponse_param;
                context.ParticipantResponses.Add(q1DResponse);
                context.SaveChanges();

                ParticipantResponse q1EResponse = new ParticipantResponse();
                q1EResponse.submitted_survey_id = newSurveyId;
                q1EResponse.question_id         = 6;
                q1EResponse.participant_answer  = Q1EResponse_param;
                context.ParticipantResponses.Add(q1EResponse);
                context.SaveChanges();

                ParticipantResponse q2Response = new ParticipantResponse();
                q2Response.submitted_survey_id = newSurveyId;
                q2Response.question_id         = 8;
                q2Response.participant_answer  = Q2Response_param;
                context.ParticipantResponses.Add(q2Response);
                context.SaveChanges();

                ParticipantResponse q3Response = new ParticipantResponse();
                q3Response.submitted_survey_id = newSurveyId;
                q3Response.question_id         = 9;
                q3Response.participant_answer  = Q3Response_param;
                context.ParticipantResponses.Add(q3Response);
                context.SaveChanges();

                ParticipantResponse q4Response = new ParticipantResponse();
                q4Response.submitted_survey_id = newSurveyId;
                q4Response.question_id         = 10;
                q4Response.participant_answer  = Q4Response_param;
                context.ParticipantResponses.Add(q4Response);
                context.SaveChanges();

                ParticipantResponse q5Response = new ParticipantResponse();
                q5Response.submitted_survey_id = newSurveyId;
                q5Response.question_id         = 11;
                q5Response.participant_answer  = Q5Response_param;
                context.ParticipantResponses.Add(q5Response);
                context.SaveChanges();
            }
        }