private static Contact ParseGoogleContact(GoogleContact googleContact) { if (googleContact == null || googleContact.Deleted) { return(null); } var contact = new Contact { Forename = googleContact.ContactEntry.Name.GivenName, Surname = googleContact.ContactEntry.Name.FamilyName, }; contact.MobileNumber = DetermineMobileNumber(googleContact); DateTime date; if (DateTime.TryParse(googleContact.ContactEntry.Birthday, out date)) { contact.DateOfBirth = date; } var gender = googleContact.ContactEntry.Websites.Where(c => c.Label == "Gender").FirstOrDefault(); if (gender != null) { contact.Gender = gender.Href.StartsWith("F", StringComparison.InvariantCultureIgnoreCase) ? Contact.Sex.Female : Contact.Sex.Male; } return(contact); }
private static Contact ParseGoogleContact(GoogleContact googleContact) { if (googleContact == null || googleContact.Deleted) return null; var contact = new Contact { Forename = googleContact.ContactEntry.Name.GivenName, Surname = googleContact.ContactEntry.Name.FamilyName, }; contact.MobileNumber = DetermineMobileNumber(googleContact); DateTime date; if (DateTime.TryParse(googleContact.ContactEntry.Birthday, out date)) contact.DateOfBirth = date; var gender = googleContact.ContactEntry.Websites.Where(c => c.Label == "Gender").FirstOrDefault(); if (gender != null) contact.Gender = gender.Href.StartsWith("F", StringComparison.InvariantCultureIgnoreCase) ? Contact.Sex.Female : Contact.Sex.Male; return contact; }