private void subscribeButton_Click(object sender, EventArgs e) { string message = ""; sendEmailMobile("Subscription"); if (emailChecked && mobileChecked) { if (isValidEmail && isValidMobile) { send2Email = new SendViaEmail(email); send2Email.Subscribe(pubForm); send2Mobile = new SendViaMobile(mobile); send2Mobile.Subscribe(pubForm); message = "Subscription successful!!!"; } else { message = "Please check your mobile/ email address"; } } else if (emailChecked && !mobileChecked) { if (isValidEmail) { message = "Subscription successful!!!"; send2Email = new SendViaEmail(email); send2Email.Subscribe(pubForm); } else { message = "Please check your email address"; } } else if (mobileChecked && !emailChecked) { if (isValidMobile) { message = "Subscription successful!!!"; send2Mobile = new SendViaMobile(mobile); send2Mobile.Subscribe(pubForm); } else { message = "Please check your mobile number"; } } MessageBox.Show(message); }
//Subscribe for a notification if subscribe button is clicked private void subscribeButton_Click(object sender, EventArgs e) { string message = ""; manager.PublishMessage(); //Check if none of the checkboxes are checked sendEmailMobile("Subscription"); //Check if the email already exists if (emailChecked) { if (manager.emailList.Contains(email)) { MessageBox.Show("The email already exists"); emailExist = true; } } //Check if the mobile already exists if (mobileChecked) { if (manager.mobileList.Contains(mobile)) { MessageBox.Show("The phone number already exists"); mobileExist = true; } } //If the email and/or mobile is valid and new, add it to the list by subscribing if (!mobileExist && !emailExist) { if (emailChecked && mobileChecked) { if (isValidEmail && isValidMobile) { send2Email = new SendViaEmail(email); send2Email.Subscribe(manager); send2Mobile = new SendViaMobile(mobile); send2Mobile.Subscribe(manager); message = "Subscription successful!!!"; } else { message = "Please check your mobile/ email address"; } } else if (emailChecked && !mobileChecked) { if (isValidEmail) { message = "Subscription successful!!!"; send2Email = new SendViaEmail(email); send2Email.Subscribe(manager); } else { message = "Please check your email address"; } } else if (mobileChecked && !emailChecked) { if (isValidMobile) { message = "Subscription successful!!!"; send2Mobile = new SendViaMobile(mobile); send2Mobile.Subscribe(manager); } else { message = "Please check your mobile number"; } } if (message != "") { MessageBox.Show(message); } } }
//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); } } }