Esempio n. 1
0
 private string UnsubscribeSubscriber(NewsletterSubscriber subscriber)
 {
     if (subscriber.IsNew)
     {
         return("Geen geldige abonnee geladen");
     }
     //subscriber.UnsubscribeDate = DateTime.Now;
     //subscriber.Save();
     subscriber.Delete();
     return("");
 }
        public JsonResult DeleteSubscriber(Guid id)
        {
            bool result = false;

            if (id != null)
            {
                NewsletterSubscriber subscriber = BaseObject.GetById <NewsletterSubscriber>(id);
                subscriber.Delete();
                result = true;
            }
            return(JsonResult.CreateResult(result));
        }
        public JsonResult DeleteAbbonementFromGroup(string NewsLetterGroupId, string SubscriberId)
        {
            Guid NewsletterGroupID = Guid.Parse(NewsLetterGroupId);
            Guid SubscriberID      = Guid.Parse(SubscriberId);

            NewsletterSubscriber Subscriber      = NewsletterSubscriber.GetById <NewsletterSubscriber>(SubscriberID);
            NewsletterGroup      SubscriberGroup = NewsletterGroup.GetById <NewsletterGroup>(NewsletterGroupID);

            if (Subscriber.SubscribedGroups.Count > 1)
            {
                Subscriber.SubscribedGroups.Remove(SubscriberGroup);
                Subscriber.Save();
            }
            else
            {
                Subscriber.Delete();
            }
            return(JsonResult.CreateResult(true, SubscriberGroup.Subscribers));
        }
Esempio n. 4
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;
            }
        }