private void OnAddContactExecute() { var newContact = new CustomerContactWrapper(new CustomerContact()); newContact.PropertyChanged += CustomerContactWrapper_PropertyChanged; Contacts.Add(newContact); Customer.Model.CustomerContacts.Add(newContact.Model); newContact.Number = ""; }
private void OnRemoveContactExecute() { SelectedContact.PropertyChanged -= CustomerContactWrapper_PropertyChanged; _repository.RemovePhoneNumber(SelectedContact.Model); //Customer.Model.CustomerContacts.Remove(SelectedContact.Model); Contacts.Remove(SelectedContact); SelectedContact = null; HasChanges = _repository.HasChanges(); ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged(); }
private void InitializeCustomerContacts(ICollection <CustomerContact> customerContacts) { foreach (var wrapper in Contacts) { wrapper.PropertyChanged -= CustomerContactWrapper_PropertyChanged; } Contacts.Clear(); foreach (var item in customerContacts) { var wrapper = new CustomerContactWrapper(item); Contacts.Add(wrapper); wrapper.PropertyChanged += CustomerContactWrapper_PropertyChanged; } }