protected void OnBeforeSave(object sender, EventArgs e) { // Check license if (!SubscriberInfoProvider.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.Subscribers, ObjectActionEnum.Insert)) { NewForm.StopProcessing = true; ShowError(GetString("LicenseVersionCheck.Subscribers")); } // Set SiteID NewForm.Data.SetValue("SubscriberSiteID", SiteContext.CurrentSiteID); string firstName = ValidationHelper.GetString(NewForm.GetFieldValue("SubscriberFirstName"), string.Empty); string lastName = ValidationHelper.GetString(NewForm.GetFieldValue("SubscriberLastName"), string.Empty); // Set full name NewForm.Data.SetValue("SubscriberFullName", string.Concat(firstName, " ", lastName)); string email = ValidationHelper.GetString(NewForm.GetFieldValue("SubscriberEmail"), string.Empty); // Check email if (email == string.Empty) { NewForm.StopProcessing = true; ShowError(GetString("Subscriber_Edit.ErrorEmptyEmail")); } else if (SubscriberInfoProvider.EmailExists(email)) { NewForm.StopProcessing = true; ShowError(GetString("Subscriber_Edit.EmailAlreadyExists")); } }
protected void ValidateValues(object sender, EventArgs e) { // Validate unsubscription template if (ValidationHelper.GetInteger(NewForm.GetFieldValue("NewsletterUnsubscriptionTemplateID"), 0) == 0) { ShowError(GetString("Newsletter_Edit.NoUnsubscriptionTemplateSelected")); NewForm.StopProcessing = true; } // Validate subscription template if (ValidationHelper.GetInteger(NewForm.GetFieldValue("NewsletterSubscriptionTemplateID"), 0) == 0) { ShowError(GetString("Newsletter_Edit.NoSubscriptionTemplateSelected")); NewForm.StopProcessing = true; } // If Template based, validate template if (GetUpperNewsletterType() == NewsletterType.TemplateBased && ValidationHelper.GetInteger(NewForm.GetFieldValue("NewsletterTemplateID"), 0) == 0) { ShowError(GetString("Newsletter_Edit.NoEmailTemplateSelected")); NewForm.StopProcessing = true; } // If Dynamic, validate schedule interval and Source page URL if (GetUpperNewsletterType() == NewsletterType.Dynamic) { if (ValidationHelper.GetString(NewForm.GetFieldValue("NewsletterDynamicURL"), string.Empty) == string.Empty) { // Source page URL can not be empty ShowError(GetString("newsletter_edit.sourcepageurlempty")); NewForm.StopProcessing = true; } if (chkSchedule.Checked) { if (!ScheduleInterval.CheckOneDayMinimum()) { // Problem occurred while setting schedule interval for dynamic newsletter ShowError(GetString("Newsletter_Edit.NoDaySelected")); NewForm.StopProcessing = true; } if (SchedulingHelper.DecodeInterval(ScheduleInterval.ScheduleInterval).StartTime == DateTime.MinValue) { ShowError(GetString("Newsletter.IncorrectDate")); NewForm.StopProcessing = true; } } } }
protected void AfterSave(object sender, EventArgs e) { if (GetUpperNewsletterSource() != NewsletterSource.Dynamic) { var templateIDsString = ValidationHelper.GetString(NewForm.GetFieldValue("NewsletterTemplateIDs"), ""); AddTemplatesToNewsletter(templateIDsString); } if ((GetUpperNewsletterSource() == NewsletterSource.Dynamic) && chkSchedule.Checked) { // If Scheduling is enabled, create task CreateTask(); } else { // Redirect to newly created newsletter Redirect(); } }
private EmailCommunicationTypeEnum GetSelectedCommunicationType() { return((EmailCommunicationTypeEnum)ValidationHelper.GetInteger(NewForm.GetFieldValue("NewsletterType"), 0)); }
/// <summary> /// Returns newsletter source (upper). /// </summary> /// <returns>Newsletter source string</returns> private string GetUpperNewsletterSource() { return(ValidationHelper.GetString(NewForm.GetFieldValue("NewsletterSource"), "").ToUpperInvariant()); }
/// <summary> /// Returns newsletter type (upper). /// </summary> /// <returns>Newsletter Type string</returns> private string GetUpperNewsletterType() { return(ValidationHelper.GetString(NewForm.GetFieldValue("NewsletterType"), "").ToUpperCSafe()); }