public void FindContacts()
 {
     var api = new ContactsApi();
     var req = new FindContactsRequest();
     req.Filters.Add(new FilterCriteria<ContactProperties> { Operation = FilterOperation.Like, TargetField = ContactProperties.LastName, Value = "Cast*" });
     api.FindContacts(req);
 }
Beispiel #2
0
        public IEnumerable<ContactInfo> FindContacts(FindContactsRequest request)
        {
            var filterExpression = string.Join(" AND ", request.Filters.Select(q => q.ToString()).ToArray());
            var message = string.Format(MessageConstants.Contacts_FindContacts, filterExpression);

            var doc = new XmlDocument();
            var resultXml = ProcessAction(message);
            doc.LoadXml(resultXml);

            return doc.DocumentElement.ChildNodes.Cast<XmlNode>()
                .First(q => "Contacts".Equals(q.Name))
                .ChildNodes.Cast<XmlNode>()
                .Select(q => ContactInfo.Create(q));
        }
Beispiel #3
0
        public IEnumerable<ContactInfo> FindContacts(string firstname, string lastname, string company)
        {
            var request = new FindContactsRequest();

            if (!string.IsNullOrWhiteSpace(firstname))
            {
                request.Filters.Add(new FilterCriteria<ContactProperties> { Operation = FilterOperation.Like, TargetField = ContactProperties.FirstName, Value = firstname });
            }

            if (!string.IsNullOrWhiteSpace(lastname))
            {
                request.Filters.Add(new FilterCriteria<ContactProperties> { Operation = FilterOperation.Like, TargetField = ContactProperties.LastName, Value = lastname });
            }

            if (!string.IsNullOrWhiteSpace(company))
            {
                request.Filters.Add(new FilterCriteria<ContactProperties> { Operation = FilterOperation.Like, TargetField = ContactProperties.CompanyName, Value = company });
            }
            var service = new ContactsApi();
            return service.FindContacts(request);
        }