示例#1
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     var person = new Person()
     {
         FirstName = txtFirstName.Text,
         LastName = txtLastName.Text
     };
     personManager.AddPerson(person);
 }
示例#2
0
 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);
 }
示例#3
0
 public void AddPerson(Person person)
 {
     persons.Add(person);
 }