Skip to content

Commit 08ba338

Browse files
committed
Modified code so that in the case of a bad EAN (like something with non-numeric characters), the EAN value will be "-1" and the property "EANText" will provide the string version of the bad EAN (for auditing purposes).
1 parent a969471 commit 08ba338

1 file changed

Lines changed: 29 additions & 7 deletions

File tree

OnixData.Standard/Version3/OnixProduct.cs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,23 +155,45 @@ public string ISBN
155155
}
156156
}
157157

158-
public long EAN
158+
public string EANText
159159
{
160160
get
161161
{
162162
OnixProductId[] ProductIdList = OnixProductIdList;
163163

164+
string TempEAN = string.Empty;
165+
if ((ProductIdList != null) && (ProductIdList.Length > 0))
166+
{
167+
OnixProductId EanProductId =
168+
ProductIdList.Where(x => (x.ProductIDType == CONST_PRODUCT_TYPE_EAN) ||
169+
(x.ProductIDType == CONST_PRODUCT_TYPE_ISBN13)).LastOrDefault();
170+
171+
if ((EanProductId != null) && !String.IsNullOrEmpty(EanProductId.IDValue))
172+
{
173+
TempEAN = EanProductId.IDValue;
174+
}
175+
}
176+
177+
return TempEAN;
178+
}
179+
}
180+
181+
public long EAN
182+
{
183+
get
184+
{
164185
long TempEAN = this.eanField;
186+
165187
if (TempEAN <= 0)
166188
{
167-
if ((ProductIdList != null) && (ProductIdList.Length > 0))
189+
if (!String.IsNullOrEmpty(EANText))
168190
{
169-
OnixProductId EanProductId =
170-
ProductIdList.Where(x => (x.ProductIDType == CONST_PRODUCT_TYPE_EAN) ||
171-
(x.ProductIDType == CONST_PRODUCT_TYPE_ISBN13)).LastOrDefault();
191+
if (!Int64.TryParse(EANText, out TempEAN))
192+
{
193+
TempEAN = -1;
194+
}
172195

173-
if ((EanProductId != null) && !String.IsNullOrEmpty(EanProductId.IDValue))
174-
TempEAN = this.eanField = Convert.ToInt64(EanProductId.IDValue);
196+
this.eanField = TempEAN;
175197
}
176198
}
177199

0 commit comments

Comments
 (0)