public static void SetContactValue(this OpenHR001Person person, vocContactType contactType, string value) { dtContact contact = (person.contact ?? new dtContact[] { }).FirstOrDefault(t => t.contactType == contactType); if (!string.IsNullOrEmpty(value)) { if (contact == null) { contact = new dtContact() { contactType = contactType, updateMode = vocUpdateMode.add, id = Guid.NewGuid().ToString() }; person.contact = (person.contact ?? new dtContact[] { }) .Concat(new dtContact[] { contact }) .ToArray(); } contact.value = value; } else { if (contact != null) { person.contact = person.contact .Where(t => t != contact) .ToArray(); } } }
public static string GetFormattedContactValue(this dtContact[] contacts, vocContactType contactType) { if (contacts == null) { return(null); } dtContact contact = contacts.FirstOrDefault(t => t.contactType == contactType); if (contact == null) { return(string.Empty); } if (string.IsNullOrEmpty(contact.value)) { return(string.Empty); } return(FormatContactValue(contactType, contact.value)); }