Skip to content

Settings and activity

1 result found

  1. 1 vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    How important is this to you?

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    An error occurred while saving the comment
    Hanan Abdelwahab commented  · 

    This a simple example to search for a contact using email or name .If you want to get all contacts , you will use " var Contacts = private_app_api.Contacts.Find().ToList()" without the where section and loop on them.

    private void GetConats()
    {
    X509Certificate2 cert = new X509Certificate2(@"C:\OpenSSL\bin\public_privatekey.pfx","Your Password");
    XeroCoreApi private_app_api = new XeroCoreApi("https://api.xero.com/api.xro/2.0/", new PrivateAuthenticator(cert),new Consumer("Your Key", "Your Password"), null
    ,new DefaultMapper(), new DefaultMapper());

    var Contacts = private_app_api.Contacts.Find().ToList().Where(c => c.Name.StartsWith(txtContactNameOrEmail.Text.Trim()) || c.EmailAddress == txtContactNameOrEmail.Text.Trim()).FirstOrDefault();
    if (Contacts != null)
    ///Uncomment the loop in case you want to get the whole list of contacts
    //for (int i = 0; i < Contacts.; i++ )
    // MessageBox.Show("The contact " + Contacts[i].FirstName + " " + Contacts[i].LastName + " is Existing with Id " + Contacts[i].Id);
    MessageBox.Show("The contact " + Contacts.FirstName + " " + Contacts.LastName + " is Existing with Id " + Contacts.Id);
    else
    MessageBox.Show("This contat doesn't exist");
    }