private void btnSave_Click(object sender, EventArgs e) { //try to create a person instance try { var person = new Person(txtFirstName.Text, txtLastName.Text, chkHasDriverLicence.Checked, txtEmail.Text); PersonCreated?.Invoke(this, person); } catch (Exception exception) // will catch validation errors and display on messagebox { MessageBox.Show(exception.Message); } }
public virtual void OnPersonCreated() { CreateNotification(EventActionType.Created); PersonCreated?.Invoke(this, new NewNotificationEventArgs(this)); }