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

CreateSurvey() public method

Creates a new Survey instance, to be persisted when SubmitChanges is called.
public CreateSurvey ( int userId, int portalId, int moduleId ) : Survey
userId int The ID of the user creating the instance.
portalId int The ID of the survey's portal.
moduleId int The ID of the module that owns the survey.
return Survey
        public Survey CreateSurvey(int userId, int portalId, int moduleId)
        {
            var createSurvey = new Survey(userId)
                                   {
                                           PortalId = portalId,
                                           ModuleId = moduleId
                                   };

            this.Context.Surveys.InsertOnSubmit(createSurvey);

            return createSurvey;
        }

Usage Example

コード例 #1
0
        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;
        }