private static CpvCode GetCpvCode(JToken value) { var cpv = new CpvCode { Code = value["CPV_CODE"]["@CODE"].ToString() }; var vocCodes = value.Value <JToken>("CPV_SUPPLEMENTARY_CODE"); if (vocCodes != null) { if (vocCodes.Type == JTokenType.Array) { cpv.VocCodes = vocCodes.Select(x => new VocCode { Code = x.Value <string>("@CODE") }).ToArray(); } else { cpv.VocCodes = new VocCode[1] { new VocCode { Code = vocCodes.Value <string>("@CODE") } }; } } return(cpv); }
private static Change ChangeCpv(CpvCode oldValue, CpvCode newValue, Type type, string property, string lotNo = null, string section = null) { var tedAttribute = GetCorrigendumAttributeAndTranslation(type, property, out var translation); return(new Change { Section = section ?? tedAttribute?.Section, LotNumber = lotNo, Label = translation, OldMainCpvCode = oldValue, NewMainCpvCode = newValue }); }
/// <summary> /// Adds a CPV XElement to the list, if there is a change. /// </summary> /// <param name="list">The list</param> /// <param name="originalValue">Original value</param> /// <param name="newValue">New value</param> /// <param name="type">Type</param> /// <param name="property">Property</param> /// <param name="lotNum">Lot number</param> /// <param name="section">Section overload</param> public static void AddCpv(this List <Change> list, CpvCode originalValue, CpvCode newValue, Type type, string property, string lotNum = null, string section = null) { var originalVocs = originalValue.VocCodes?.Select(x => x.Code).ToList() ?? new List <string>(); var newVocs = newValue.VocCodes?.Select(x => x.Code).ToList() ?? new List <string>(); if (((originalValue.Code == newValue.Code) || (string.IsNullOrEmpty(originalValue.Code) && string.IsNullOrEmpty(newValue.Code))) && !(originalVocs.Except(newVocs).Any() || newVocs.Except(originalVocs).Any())) { return; } list.Add(ChangeCpv(originalValue, newValue, type, property, lotNum, section)); }