Ejemplo n.º 1
0
        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();
                }
            }
        }
Ejemplo n.º 2
0
 private void ShowSelectedContactTabs(MemberModel member)
 {
     if (member != null)
     {
         _originalMember = member.Clone();
         if (CanViewContactDetails)
             ContactDetailsContent = new ContactDetailsView(member.Contact, true, member);
         if (CanViewCorrespondence)
             CorrespondenceContent = new CorrespondenceView(member.Contact,"Member");
         if (CanViewActivity)
             ActivityContent = new ActivityView(member.Contact);
         if (CanViewAccounts)
             AccountsContent = new AccountsView(member.Contact);
         if (CanViewMemberDetails)
             MemberDetailsContent = new MemberDetailsView(member);
         if (CanViewNoteDetails)
             MemberNotesContent = new MemberNotesView(member);
         if (CanViewUpdateDetails)
             MemberUpdateDetailsContent = new MemberUpdateDetailsView(member);
     }
 }
Ejemplo n.º 3
0
        public ContactDetailsViewModel(ContactModel model, bool isFromMembership, MemberModel member)
        {
            IsFromMembership = isFromMembership;

            if (member != null)
            {
                _originalMember = member.Clone();
                Member = member;
            }

            var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve<IDataUnitLocator>();
            if (IsFromMembership)
                _membershipDataUnit = dataUnitLocator.ResolveDataUnit<IMembershipDataUnit>();
            else
                _contactsDataUnit = dataUnitLocator.ResolveDataUnit<IContactsDataUnit>();

            SaveChangesCommand = new RelayCommand(SaveChangesCommandExecute, SaveChangesCommandCanExecute);

            if (IsFromMembership)
                CanEdit = AccessService.Current.UserHasPermissions(Resources.PERMISSION_MEMBERSHIP_EDIT_CONTACT_ALLOWED);
            else
                CanEdit = AccessService.Current.UserHasPermissions(Resources.PERMISSION_EDIT_CONTACT_ALLOWED);

            if (IsFromMembership)
                ProcessContact(Member.Contact);
            else
                ProcessContact(model);
        }
Ejemplo n.º 4
0
 private void ProcessMember(MemberModel member)
 {
     Member = member;
     _originalMember = Member.Clone();
     Member.PropertyChanged += MemberModelOnPropertyChanged;
 }