partial void DeleteSurvey(Survey instance);
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; }
partial void InsertSurvey(Survey instance);
partial void UpdateSurvey(Survey instance);
/// <summary> /// Called when a new <see cref="Survey"/> is inserted. /// </summary> /// <param name="instance">The new <see cref="Survey"/> instance.</param> partial void InsertSurvey(Survey instance) { instance.CreationDate = DateTime.Now; instance.RevisionDate = DateTime.Now; this.ExecuteDynamicInsert(instance); }
/// <summary> /// Called when an existing <see cref="Survey"/> is updated. /// </summary> /// <param name="instance">The existing <see cref="Survey"/> instance.</param> partial void UpdateSurvey(Survey instance) { instance.RevisionDate = DateTime.Now; this.ExecuteDynamicUpdate(instance); }
/// <summary> /// Creates a new <see cref="Survey"/> instance, to be persisted when <see cref="SubmitChanges"/> is called. /// </summary> /// <param name="userId">The ID of the user creating the instance.</param> /// <param name="portalId">The ID of the survey's portal.</param> /// <param name="moduleId">The ID of the module that owns the survey.</param> /// <returns>The new <see cref="Survey"/> instance</returns> 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; }
/// <summary> /// Renders the survey from this survey. /// </summary> /// <param name="placeHolder">The place holder.</param> /// <param name="readOnly">if set to <c>true</c> [read only].</param> /// <param name="showRequiredNotation">if set to <c>true</c> [show required notation].</param> /// <param name="validationProvider">The validation provider.</param> /// <param name="localizer">Localizes text.</param> public void Render(PlaceHolder placeHolder, bool readOnly, bool showRequiredNotation, ValidationProviderBase validationProvider, ILocalizer localizer) { Survey.RenderSurvey(this, placeHolder, readOnly, showRequiredNotation, validationProvider, localizer); }
/// <summary> /// Raises the <see cref="Control.Init"/> event. /// </summary> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected override void OnInit(EventArgs e) { if (this.Survey == null) { // set this.survey to a valid survey, so that calls from markup don't fail this.survey = new Survey(this.UserId); return; } this.CreateGraphs(); this.CreateGrid(); this.Load += this.Page_Load; this.ResponseGrid.NeedDataSource += this.ResponseGrid_NeedDataSource; this.ResponseGrid.ItemCreated += this.ResponseGrid_ItemCreated; base.OnInit(e); }