private void btnOk_Click(object sender, EventArgs e) { var person = new Person() { FirstName = txtFirstName.Text, LastName = txtLastName.Text }; personManager.AddPerson(person); }
public void AddPerson(Person person) { if (person.ID > 0) { if (persons.Select(p => p.ID).Contains(person.ID)) { throw new Exception($"Person with ID {person.ID} is already existing! You can leave ID to be generated by PersonManager class. "); } } else { person.ID = getNewPersonID(); } persons.Add(person); }
public void AddPerson(Person person) { persons.Add(person); }