public MainPresenter(IMainView view, IPersonData personData, IComboBoxData boxData) { _view = view; _personData = personData; _boxData = boxData; _view.Contact += (v, y) => ShowContact(v, null, y); _view.EditContact += (v, u, y) => ShowContact(v, u, y); _view.DeleteContact += OnDeleteContact; LoadContacts(); }
public static void Seed(IComboBoxData comboBoxData, ISqlDataAccess sql) { if (!comboBoxData.LoadComboBox().Item1.Any()) { var phoneType = PhoneType(); var addressType = AddressType(); var contact = Person(); var contactPhone = Phone(); var contactAddress = Address(); try { sql.StartTransaction(); foreach (var item in phoneType) { var Id = sql.SaveDataInTransaction("dbo.spPhoneNumberType_Insert", item); contactPhone.PhoneNumberTypeID = Convert.ToInt32(Id); } foreach (var item in addressType) { var Id = sql.SaveDataInTransaction("dbo.spAddressType_Insert", item); contactAddress.AddressTypeID = Convert.ToInt32(Id); } var contactId = sql.SaveDataInTransaction("dbo.spPerson_Insert", contact); contact.Id = Convert.ToInt32(contactId); contactPhone.PersonID = contact.Id; contactAddress.PersonID = contact.Id; sql.SaveDataInTransaction("dbo.spPhone_Insert", contactPhone); sql.SaveDataInTransaction("dbo.spAddress_Insert", contactAddress); sql.CommitTransaction(); } catch { sql.RollbackTransaction(); throw; } } }
public ContactPresenter(IContactView view, IPersonData personData, IComboBoxData boxData) { _view = view; _personData = personData; _boxData = boxData; ContactDetails = new PersonDetailModel(); LoadTypes(); _view.CreateContact += OnCreateContact; _view.EditContact += OnEditContact; _view.AddPhone += OnAddPhone; _view.AddAddress += OnAddAddress; _view.PhoneTypeSelected += OnPhoneTypeSelected; _view.AddressTypeSelected += OnAddressTypeSelected; _view.EditAddress += OnEditAddress; _view.EditPhone += OnEditPhone; _view.DeleteAddress += OnDeleteAddress; _view.DeletePhone += OnDeletePhone; }