Пример #1
0
 public void GetPeople(Dispatcher dispatcher)
 {
     IAddressBookService service = new AddressBookServiceClient();
     service.BeginGetPeople(delegate(IAsyncResult result)
     {
         ObservableCollection<Person> people = service.EndGetPeople(result);
         dispatcher.BeginInvoke(delegate
         {
             _people.Clear();
             foreach (Person person in people)
             {
                 _people.Add(person);
             }
         });
     }, null);
 }
Пример #2
0
        public void GetPeople(Dispatcher dispatcher)
        {
            IAddressBookService service = new AddressBookServiceClient();

            service.BeginGetPeople(delegate(IAsyncResult result)
            {
                ObservableCollection <Person> people = service.EndGetPeople(result);
                dispatcher.BeginInvoke(delegate
                {
                    _people.Clear();
                    foreach (Person person in people)
                    {
                        _people.Add(person);
                    }
                });
            }, null);
        }
Пример #3
0
        private async void LoadContacts()
        {
            AddressBookServiceClient proxy = new AddressBookServiceClient("BasicHttpBinding_IAddressBookService");

            try
            {

                Contacts = await proxy.GetContactAsync();
            }
            catch (Exception e)
            {
                MessageBox.Show("Error " + e.Message);
            }
            finally
            {
                proxy.Close();
            }


        }
Пример #4
0
 private async void ChangePhoneNumber()
 {
     AddressBookServiceClient proxy = new AddressBookServiceClient("BasicHttpBinding_IAddressBookService");
     try
     {    
         await proxy.ChangePhoneNumberAsync(_id,_phoneNumber.Insert(0,"(").Insert(4,") ").Insert(9,"-"));
         Contacts = await proxy.FindContactbyPhoneAsync(_phoneNumber);
     }
     catch (Exception e)
     {
         MessageBox.Show("Error " + e.Message);
     }
     finally
     {
         proxy.Close();
     }
 }
Пример #5
0
        private async void AddContact()
        {
            Contact newContact = new Contact();
            AddressBookServiceClient proxy = new AddressBookServiceClient("BasicHttpBinding_IAddressBookService");
            

            try
            {
                string[] fio = _fullName.Trim().Split(' ');

                var buffContacts = await proxy.GetContactAsync();
                newContact.FullName = _fullName.Trim();
                newContact.LastName = fio[0];
                newContact.FirstName = fio[1];
                newContact.MiddleName = fio[2];
                //newContact.PhoneNumber = _phoneNumber.Insert(0,"(").Insert(4,") ").Insert(9,"-");
                newContact.PhoneNumber = _phoneNumber;
                newContact.Id = buffContacts.Count + 1;

                await proxy.AddContactAsync(newContact);
                Contacts = await proxy.GetContactAsync();

            }
            catch (Exception e)
            {
                MessageBox.Show("Error " + e.Message);
            }
            finally
            {
                proxy.Close();
            }
        }
Пример #6
0
 private async void FindContact()
 {
     AddressBookServiceClient proxy = new AddressBookServiceClient("BasicHttpBinding_IAddressBookService");
     try
     {
         Contacts = await proxy.FindContactbyPhoneAsync(_phoneNumber);
     }
     catch (Exception e)
     {
         MessageBox.Show("Error " + e.Message);
     }
     finally
     {
         proxy.Close();
     }
 }
Пример #7
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     _serviceReference = new AddressBookServiceClient();
     PopulateGrid();
 }