Пример #1
0
        public void ResendVerificationButton_Click(object sender, EventArgs e)
        {
            BaseCollection <NewsletterSubscriber> subscribers = BaseCollection <NewsletterSubscriber> .Get("Name = '" + TextboxEmail.Text.Trim() + "'");

            if (subscribers.Count > 0)
            {
                NewsletterService.SendVerificationEmail(subscribers[0]);
            }
        }
Пример #2
0
        public void SubmitButton_Click(object sender, EventArgs e)
        {
            if ((TextboxEmail.Text.Trim() != "" && BitPlate.Domain.Utils.EmailManager.isValidEmailAddress(TextboxEmail.Text.Trim())) || (TextboxEmail.Text.Trim() == "*****@*****.**"))
            {
                BaseCollection <NewsletterSubscriber> subscribers = BaseCollection <NewsletterSubscriber> .Get("Name = '" + TextboxEmail.Text.Trim() + "'");

                if (subscribers.Count > 0)
                {
                    //if (this.PanelErrorRegister != null) this.PanelErrorRegister.Visible = true;
                    this.ErrorPanel.Visible = true;
                    this.ErrorLabel.Text    = "Dit emailadres is al geabonneerd.";
                }
                else
                {
                    NewsletterSubscriber subscriber = new NewsletterSubscriber();
                    subscriber.Email       = TextboxEmail.Text.Trim();
                    subscriber.Name        = (this.TextboxName != null) ? this.TextboxName.Text : "";
                    subscriber.NamePrefix  = (this.TextboxNamePrefix != null) ? this.TextboxNamePrefix.Text : "";
                    subscriber.ForeName    = (this.TextboxForeName != null) ? this.TextboxForeName.Text : "";
                    subscriber.CompanyName = (this.TextboxCompany != null) ? this.TextboxCompany.Text : "";

                    if (RadioSexeMale != null && RadioSexeMale.Checked)
                    {
                        subscriber.Gender = BaseUser.SexeEnum.Male;
                    }

                    if (RadioSexeFemale != null && RadioSexeFemale.Checked)
                    {
                        subscriber.Gender = BaseUser.SexeEnum.Female;
                    }

                    if (RadioSexeCompany != null && RadioSexeCompany.Checked)
                    {
                        subscriber.Gender = BaseUser.SexeEnum.Company;
                    }

                    //simple user link
                    //BaseCollection<SiteUser> Users = BaseCollection<SiteUser>.Get("Email = '" + subscriber.Email + "'");
                    //if (Users.Count > 0)
                    //{
                    //    subscriber.User = Users[0];
                    //}
                    subscriber.Save();

                    foreach (NewsletterGroup group in this.NewsletterGroups.Where(c => c.IsMandatoryGroup))
                    {
                        subscriber.SubscribedGroups.Add(group);
                    }

                    foreach (ListItem li in this.NewsGroupCheckBoxList.Items)
                    {
                        if (li.Selected)
                        {
                            Guid ID;
                            Guid.TryParse(li.Value, out ID);
                            NewsletterGroup group = BaseObject.GetById <NewsletterGroup>(ID);
                            subscriber.SubscribedGroups.Add(group);
                        }
                    }

                    subscriber.Save();

                    if (subscriber.SubscribedGroups.Count > 0)
                    {
                        this.TextboxEmail.Visible = false;
                        this.LoadSettings();
                        //Koppel siteuser met subscriber (als aanwezig)
                        //SiteUser user = BaseObject.GetFirst<SiteUser>("FK_Site = '" + SessionObject.CurrentSite.ID.ToString() + "' AND Email = '" + subscriber.Email + "'");
                        //if (user != null)
                        //{
                        //    subscriber.User = user;
                        //    subscriber.Save();
                        //}

                        if (this.PanelRegisterFrom != null)
                        {
                            this.PanelRegisterFrom.Visible = false;
                        }
                        if (this.Settings.ContainsKey("SendVerifiationEmail") && (bool)this.Settings["SendVerifiationEmail"])
                        {
                            NewsletterService.SendVerificationEmail(subscriber);
                            this.LoadModuleObject();
                            //if (this.PanelVerificationRequest != null) this.PanelVerificationRequest.Visible = true;
                            this.SuccessPanel.Visible = true;
                            this.SuccessLabel.Text    = "Wij hebben u een verificatie email verstuurd. In deze email zit een link om uw emailadres te activeren.";
                        }
                        else
                        {
                            //if (this.PanelSuccessRegister != null) this.PanelSuccessRegister.Visible = true;
                            this.SuccessPanel.Visible = true;
                            this.SuccessLabel.Text    = "U ontvangt vanaf nu onze nieuwsbrief.";
                            subscriber.Confirmed      = true;
                            subscriber.Save();
                        }
                        this.HandleNavigation();
                    }
                    else
                    {
                        //if (this.PanelErrorRegister != null) this.PanelErrorRegister.Visible = true;
                        this.ErrorPanel.Visible = true;
                        this.ErrorLabel.Text    = "U heeft geen interessegebied(en) geselecteerd.";
                        subscriber.Delete();
                    }
                }
            }
            else
            {
                this.ErrorPanel.Visible = true;
                this.ErrorLabel.Text    = "Dit emailadres is ongeldig";
                //if (this.PanelErrorRegister != null) this.PanelErrorRegister.Visible = true;
            }
        }