private void UpdateCitationDateForType(CI_Citation_Type citation, string dateType, DateTime? incomingDateTime) { bool updated = false; string updatedValue = null; if (incomingDateTime.HasValue) { updatedValue = incomingDateTime.Value.ToString("yyyy-MM-dd"); } if (citation.date != null) { foreach (var currentDate in citation.date) { if (currentDate.CI_Date != null && currentDate.CI_Date.dateType != null && currentDate.CI_Date.dateType.CI_DateTypeCode != null && currentDate.CI_Date.dateType.CI_DateTypeCode.codeListValue == dateType) { currentDate.CI_Date.date.Item = updatedValue; updated = true; } } } else { citation.date = new CI_Date_PropertyType[0]; } if (!updated) { CI_Date_PropertyType[] newArray = new CI_Date_PropertyType[] { new CI_Date_PropertyType { CI_Date = new CI_Date_Type { date = new Date_PropertyType { Item = updatedValue }, dateType = new CI_DateTypeCode_PropertyType { CI_DateTypeCode = new CodeListValue_Type { codeList = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#CI_DateTypeCode", codeListValue = dateType } } } } }; citation.date = citation.date.Concat(newArray).ToArray(); } }
private DateTime? GetDateFromCitationWithType(CI_Citation_Type citation, string dateType) { DateTime? date = null; if (citation.date != null) { foreach (var currentDate in citation.date) { if (currentDate.CI_Date != null && currentDate.CI_Date.dateType != null && currentDate.CI_Date.dateType.CI_DateTypeCode != null && currentDate.CI_Date.dateType.CI_DateTypeCode.codeListValue == dateType && currentDate.CI_Date.date != null && currentDate.CI_Date.date.Item != null) { date = ParseDateProperty(currentDate.CI_Date.date); break; } } } return date; }