Пример #1
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();
            }


        }
Пример #2
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();
            }
        }
Пример #3
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();
     }
 }
Пример #4
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();
     }
 }