Engage.Survey.Entities.SurveyRepository.LoadSurvey C# (CSharp) Method

LoadSurvey() public method

Loads the survey.
public LoadSurvey ( int surveyId ) : Survey
surveyId int The survey id.
return Survey
        public Survey LoadSurvey(int surveyId)
        {
            return this.Context.Surveys.SingleOrDefault(s => s.SurveyId == surveyId);
        }

Same methods

SurveyRepository::LoadSurvey ( int surveyId, int moduleId ) : Survey

Usage Example

        public int UpdateSurvey(Survey survey)
        {
            int moduleId;
            Survey surveyToUpdate;
            var surveyRepository = new SurveyRepository();
            if (survey.SurveyId > 0)
            {
                surveyToUpdate = surveyRepository.LoadSurvey(survey.SurveyId);
                surveyToUpdate.RevisingUser = surveyToUpdate.Sections[0].RevisingUser = survey.RevisingUser;
                moduleId = surveyToUpdate.ModuleId;
            }
            else
            {
                surveyToUpdate = surveyRepository.CreateSurvey(survey.RevisingUser, survey.PortalId, survey.ModuleId);
                moduleId = survey.ModuleId;
            }

            if (!this.CanEditModule(moduleId))
            {
                this.DenyAccess();
            }

            // TODO: store dates in UTC
            surveyToUpdate.Text = survey.Text;
            surveyToUpdate.PortalId = survey.PortalId;
            surveyToUpdate.ModuleId = survey.ModuleId;
            surveyToUpdate.ShowText = true;

            surveyToUpdate.StartDate = survey.StartDate;
            surveyToUpdate.PreStartMessage = survey.PreStartMessage;
            surveyToUpdate.EndDate = survey.EndDate;
            surveyToUpdate.PostEndMessage = survey.PostEndMessage;

            surveyToUpdate.SendNotification = survey.SendNotification;
            surveyToUpdate.NotificationFromEmailAddress = survey.NotificationFromEmailAddress;
            surveyToUpdate.NotificationToEmailAddresses = survey.NotificationToEmailAddresses;
            surveyToUpdate.SendThankYou = survey.SendThankYou;
            surveyToUpdate.ThankYouFromEmailAddress = survey.ThankYouFromEmailAddress;

            surveyToUpdate.FinalMessageOption = survey.FinalMessageOption;
            surveyToUpdate.FinalMessage = survey.FinalMessage;
            surveyToUpdate.FinalUrl = survey.FinalUrl;

            surveyToUpdate.Sections.First().Text = survey.Sections.First().Text;
            surveyToUpdate.Sections.First().ShowText = true;

            surveyRepository.SubmitChanges();

            return surveyToUpdate.SurveyId;
        }
All Usage Examples Of Engage.Survey.Entities.SurveyRepository::LoadSurvey