private void unsubBtn_Click(object sender, EventArgs e) { bool flg = false; if (this.emailAddress != String.Empty) { SendViaEmail sendViaEmail = new SendViaEmail(this.emailAddress); sendViaEmail.Unsubscribe(this.publisher); MessageBox.Show(this.emailAddress + " unsubscribe succesfully!"); this.emailAddress = String.Empty; flg = true; } if (this.mobileNumber != String.Empty) { SendViaMobile sendViaMobile = new SendViaMobile(this.mobileNumber); sendViaMobile.Unsubscribe(this.publisher); MessageBox.Show(this.mobileNumber + " unsubscribe succesfully!"); this.mobileNumber = String.Empty; flg = true; } if (flg == true) { this.Close(); } }
public void Unsubscribe(Publisher pub) { Dictionary <string, SendViaMobile> phoneDic = pub.getPhoneDic(); SendViaMobile sendViaMobile = phoneDic[this.getMobile()]; pub.publishmsg -= sendViaMobile.sendMsgViaMobile; pub.removeFromList(this, "mobile"); }