コード例 #1
0
 private void unsubscribeButton_Click(object sender, EventArgs e)
 {
     sendEmailMobile("Unsubscription");
     if (emailChecked && mobileChecked)
     {
         if (isValidEmail && isValidMobile)
         {
             MessageBox.Show("Unsubscription successful!!!");
             send2Email = new SendViaEmail(email);
             send2Email.Unsubscribe(pubForm);
             send2Mobile = new SendViaMobile(mobile);
             send2Mobile.Unsubscribe(pubForm);
         }
         else
         {
             MessageBox.Show("Please check your mobile/ email address");
         }
     }
     else if (emailChecked && !mobileChecked)
     {
         if (isValidEmail)
         {
             send2Email = new SendViaEmail(email);
             send2Email.Unsubscribe(pubForm);
         }
         else
         {
             MessageBox.Show("Please check your email address");
         }
     }
     else if (mobileChecked && !emailChecked)
     {
         if (isValidMobile)
         {
             send2Mobile = new SendViaMobile(mobile);
             send2Mobile.Unsubscribe(pubForm);
         }
         else
         {
             MessageBox.Show("Please check your mobile number");
         }
     }
 }
コード例 #2
0
        //Unsubscribe for a notification if unsubscribe button is clicked
        private void unsubscribeButton_Click(object sender, EventArgs e)
        {
            string message = "";

            manager.PublishMessage();

            ////Check if none of the checkboxes are checked
            sendEmailMobile("Unsubscription");

            //Check if the email doesnot exist for unsubscription
            if (emailChecked)
            {
                if (!manager.emailList.Contains(email))
                {
                    MessageBox.Show("The email has not subscribed");
                    emailNotFound = true;
                }
            }

            //Check if the mobile doesnot exist for unsubscription
            if (mobileChecked)
            {
                if (!manager.mobileList.Contains(mobile))
                {
                    MessageBox.Show("The phone number has not subscribed");
                    mobileNotFound = true;
                }
            }

            //Unsubscribe if email and/or mobile are valid and exist in the list
            if (!emailNotFound && !mobileNotFound)
            {
                if (emailChecked && mobileChecked)
                {
                    if (isValidEmail && isValidMobile)
                    {
                        message    = "Unsubscription successful!!!";
                        send2Email = new SendViaEmail(email);
                        send2Email.Unsubscribe(manager);
                        send2Mobile = new SendViaMobile(mobile);
                        send2Mobile.Unsubscribe(manager);
                    }
                    else
                    {
                        message = "Please check your mobile/ email address";
                    }
                }
                else if (emailChecked && !mobileChecked)
                {
                    if (isValidEmail)
                    {
                        message    = "Unsubscription successful!!!";
                        send2Email = new SendViaEmail(email);
                        send2Email.Unsubscribe(manager);
                    }
                    else
                    {
                        message = "Please check your email address";
                    }
                }
                else if (mobileChecked && !emailChecked)
                {
                    if (isValidMobile)
                    {
                        message     = "Unsubscription successful!!!";
                        send2Mobile = new SendViaMobile(mobile);
                        send2Mobile.Unsubscribe(manager);
                    }
                    else
                    {
                        message = "Please check your mobile number";
                    }
                }
                if (message != "")
                {
                    MessageBox.Show(message);
                }
            }
        }