private static Tuple <List <XElement>, ChangeType> NewValue(Change change) { List <XElement> newValue; ChangeType type; if (change.NewText != null && change.NewText.Length > 0 && !string.IsNullOrEmpty(change.NewText[0])) { type = ChangeType.Text; newValue = new List <XElement> { TedHelpers.PElement("TEXT", change.NewText) }; } else if (change.NewNutsCodes != null && change.NewNutsCodes.Length > 0 && !string.IsNullOrEmpty(change.NewNutsCodes[0])) { type = ChangeType.Nuts; newValue = new List <XElement> { TedHelpers.PElement("NUTS", change.NewText) }; } else if (change.NewDate != null && change.NewDate != DateTime.MinValue) { type = ChangeType.Date; newValue = new List <XElement> { TedHelpers.DateTimeElement("DATE_TIME", change.NewDate) }; } else if (change.NewMainCpvCode != null && !string.IsNullOrEmpty(change.NewMainCpvCode.Code)) { type = ChangeType.Cpv; newValue = new List <XElement> { TedHelpers.Element("CPV_MAIN", TedHelpers.ElementWithAttribute("CPV_CODE", "CODE", change.NewMainCpvCode.Code), change.NewMainCpvCode.VocCodes?.Select(x => TedHelpers.ElementWithAttribute("CPV_SUPPLEMENTARY_CODE", "CODE", x.Code))) }; } else if (change.NewAdditionalCpvCodes != null && change.NewAdditionalCpvCodes.Count > 0) { type = ChangeType.Cpv; newValue = change.NewAdditionalCpvCodes.Select(x => TedHelpers.Element("CPV_ADDITIONAL", TedHelpers.ElementWithAttribute("CPV_CODE", "CODE", x.Code), x.VocCodes?.Select(y => TedHelpers.ElementWithAttribute("CPV_SUPPLEMENTARY_CODE", "CODE", y.Code))) ).ToList(); } else { type = ChangeType.Undefined; newValue = null; } return(new Tuple <List <XElement>, ChangeType>(newValue, type)); }