public async Task ShowReleventContact() { var allcontacts = await _membershipDataUnit.ContactsRepository.GetAllAsyncWithoutRefresh(contact => contact.LastName == Member.Contact.LastName && contact.Email == Member.Contact.Email); var contacts = new ObservableCollection<ContactModel>( allcontacts.OrderBy(contact => contact.LastName).Select(contact => new ContactModel(contact))); if (contacts.Count > 0) { RaisePropertyChanged("DisableParentWindow"); var relevantContactsView = new ReleventContactsView(contacts); relevantContactsView.ShowDialog(); RaisePropertyChanged("EnableParentWindow"); if (relevantContactsView.DialogResult != null && relevantContactsView.DialogResult.Value) { if (IsExistingContact) _membershipDataUnit.ContactsRepository.Refresh(Member.Contact.Contact); if (relevantContactsView.ViewModel.Contact.Contact.Member != null) { Member = new MemberModel(relevantContactsView.ViewModel.Contact.Contact.Member) { Contact = relevantContactsView.ViewModel.Contact, Category = MemberCategories.FirstOrDefault(category => category.ID == relevantContactsView.ViewModel.Contact.Contact.Member.MembershipCategory.ID) }; Member.Contact.PropertyChanged += Contact_PropertyChanged; _isEditMode = true; IsExistingMember = true; _originalMember = Member.Clone(); SaveCommand.RaiseCanExecuteChanged(); } else { Member.Contact = relevantContactsView.ViewModel.Contact; Member.Member.ID = Member.Contact.Contact.ID; Member.Contact.PropertyChanged += Contact_PropertyChanged; } IsExistingContact = true; IsIgnored = true; if (IsOkButtonClick) { if (!_isEditMode) SaveContactChangesAddMember(); } } if (relevantContactsView.DialogResult == null || !relevantContactsView.DialogResult.Value) { if (IsOkButtonClick) { _membershipDataUnit.ContactsRepository.Add(Member.Contact.Contact); SaveContactChangesAddMember(); } else IsIgnored = true; } } else { if (IsOkButtonClick) { if (!IsExistingContact) _membershipDataUnit.ContactsRepository.Add(Member.Contact.Contact); SaveContactChangesAddMember(); } } }
public async Task ShowReleventContact() { List<Contact> allcontacts; if (IsFromMembership) allcontacts = await _membershipDataUnit.ContactsRepository.GetAllAsyncWithoutRefresh(contact => contact.LastName == ContactModel.LastName && contact.Email == ContactModel.Email); else allcontacts = await _contactsDataUnit.ContactsRepository.GetAllAsyncWithoutRefresh(contact => contact.LastName == ContactModel.LastName && contact.Email == ContactModel.Email); if (allcontacts.Count > 0) { var contacts = new ObservableCollection<ContactModel>(allcontacts.OrderBy(contact => contact.LastName).Select(contact => new ContactModel(contact))); RaisePropertyChanged("DisableParentWindow"); var view = new ReleventContactsView(contacts); view.ShowDialog(); RaisePropertyChanged("EnableParentWindow"); if (view.DialogResult != null && view.DialogResult.Value) { ContactModel = view.ViewModel.Contact; IsExistingContact = true; RaisePropertyChanged("CloseDialog"); } if (view.DialogResult == null || !view.DialogResult.Value) IsIgnored = true; } else { if (IsOkButtonClick) { await SaveContact(); } } }