private void btnUnsubscribe_Click(object sender, EventArgs e) { if (chkEmail.Checked) { string email = txtEmail.Text; eCustomer = new SendViaEmail(email); SendViaEmail removeItem = null; foreach (SendViaEmail item in CustomersList.EmailCustomers) { // MessageBox.Show(string.Format("{0}",string.Compare(item.ToString(),pCustomer.ToString()))); if (string.Compare(item.ToString(), eCustomer.ToString()) == 0) { item.UnSubscribe(publisher); removeItem = item; MessageBox.Show(String.Format("Email {0} UnSubscribed", email)); } } CustomersList.EmailCustomers.Remove(removeItem); } if (chkMobile.Checked) { string mobile = txtMobile.Text; pCustomer = new SendViaMobile(mobile); SendViaMobile removeItem = null; foreach (SendViaMobile item in CustomersList.MobileCustomers) { // MessageBox.Show(string.Format("{0}",string.Compare(item.ToString(),pCustomer.ToString()))); if (string.Compare(item.ToString(), pCustomer.ToString()) == 0) { item.UnSubscribe(publisher); removeItem = item; MessageBox.Show(String.Format("Mobile {0} UnSubscribed", mobile)); } } CustomersList.MobileCustomers.Remove(removeItem); } }
private void btnSubscribe_Click(object sender, EventArgs e) { //Subscribe email if (chkEmail.Checked && VerifyEmail()) { string email = txtEmail.Text; eCustomer = new SendViaEmail(email); //validate duplicate if (!(IsDuplicate <SendViaEmail>(eCustomer))) { eCustomer.Subscribe(publisher); CustomersList.EmailCustomers.Add(eCustomer); MessageBox.Show(String.Format("Your email {0} Subscribed successfully", email)); } else { MessageBox.Show("email already subscribed"); } } //subscribe mobile if (chkMobile.Checked && VerifyMobile()) { string mobile = txtMobile.Text; pCustomer = new SendViaMobile(mobile); //validate duplicate if (!(IsDuplicate <SendViaMobile>(pCustomer))) { pCustomer.Subscribe(publisher); CustomersList.MobileCustomers.Add(pCustomer); MessageBox.Show(String.Format("Your mobile {0} Subscribed successfully", mobile)); } else { MessageBox.Show("Mobile already subscribed"); } } }