Пример #1
0
 /// <summary>Seeds a database.</summary>
 /// <param name="source">The database to seed.</param>
 /// <param name="contacts">The contacts to seed with.</param>
 /// <remarks>
 /// Extension method to see a database.
 /// </remarks>
 public static void Seed(this IContactDatabase source, Contact[] contacts)
 {
     foreach (var contact in contacts)
     {
         source.Add(contact);
     }
 }
Пример #2
0
        private void OnContactAdd(object sender, EventArgs e)
        {
            var form = new ContactForm();

            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            try
            {
                _contactDatabase.Add(form.Contact);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            RefreshContacts();
        }