Esempio n. 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);
 }
Esempio n. 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);
        }
        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();
            }


        }
 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();
     }
 }
        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();
            }
        }
 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();
     }
 }
Esempio n. 7
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     _serviceReference = new AddressBookServiceClient();
     PopulateGrid();
 }