private void OnContactUpdated(ContactsDetailViewModel source, Contact updatedContact)
        {
            var contact = Contacts.Single(c => c.Id == updatedContact.Id);

            contact.FirstName   = updatedContact.FirstName;
            contact.Surname     = updatedContact.Surname;
            contact.PhoneNumber = updatedContact.PhoneNumber;
            contact.Email       = updatedContact.Email;
            contact.IsBlocked   = updatedContact.IsBlocked;
        }
Ejemplo n.º 2
0
        private async void AddContact()
        {
            var contact   = new ContactViewModel();
            var viewModel = new ContactsDetailViewModel(contact, _pageService, _contactStore);

            // Regsiter event handler before navigation to prevent a null exception
            viewModel.ContactAdded += (source, c) =>
            {
                Contacts.Add(new ContactViewModel(c));
            };

            await _pageService.PushAsync(new ContactsDetailPage(viewModel));
        }
Ejemplo n.º 3
0
        private void ViewContact(ContactViewModel contact)
        {
            if (contact == null)
            {
                return;
            }

            SelectedContact = null;

            var contactsDetailVM = new ContactsDetailViewModel(contact, _pageService, _contactStore);

            // Regsiter event handler before navigation to prevent a null exception
            contactsDetailVM.ContactUpdated += (source, updatedContact) =>
            {
                contact.FirstName   = updatedContact.FirstName;
                contact.Surname     = updatedContact.Surname;
                contact.PhoneNumber = updatedContact.PhoneNumber;
                contact.IsBlocked   = updatedContact.IsBlocked;
            };

            _pageService.PushAsync(new ContactsDetailPage(contactsDetailVM));
        }