Skip to content

Commit a969471

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 239e2b7 commit a969471

1 file changed

Lines changed: 29 additions & 7 deletions

File tree

OnixData/Version3/OnixProduct.cs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,23 +160,45 @@ public string ISBN
160160
}
161161
}
162162

163-
public long EAN
163+
public string EANText
164164
{
165165
get
166166
{
167167
OnixProductId[] ProductIdList = OnixProductIdList;
168168

169+
string TempEAN = string.Empty;
170+
if ((ProductIdList != null) && (ProductIdList.Length > 0))
171+
{
172+
OnixProductId EanProductId =
173+
ProductIdList.Where(x => (x.ProductIDType == CONST_PRODUCT_TYPE_EAN) ||
174+
(x.ProductIDType == CONST_PRODUCT_TYPE_ISBN13)).LastOrDefault();
175+
176+
if ((EanProductId != null) && !String.IsNullOrEmpty(EanProductId.IDValue))
177+
{
178+
TempEAN = EanProductId.IDValue;
179+
}
180+
}
181+
182+
return TempEAN;
183+
}
184+
}
185+
186+
public long EAN
187+
{
188+
get
189+
{
169190
long TempEAN = this.eanField;
191+
170192
if (TempEAN <= 0)
171193
{
172-
if ((ProductIdList != null) && (ProductIdList.Length > 0))
194+
if (!String.IsNullOrEmpty(EANText))
173195
{
174-
OnixProductId EanProductId =
175-
ProductIdList.Where(x => (x.ProductIDType == CONST_PRODUCT_TYPE_EAN) ||
176-
(x.ProductIDType == CONST_PRODUCT_TYPE_ISBN13)).LastOrDefault();
196+
if (!Int64.TryParse(EANText, out TempEAN))
197+
{
198+
TempEAN = -1;
199+
}
177200

178-
if ((EanProductId != null) && !String.IsNullOrEmpty(EanProductId.IDValue))
179-
TempEAN = this.eanField = Convert.ToInt64(EanProductId.IDValue);
201+
this.eanField = TempEAN;
180202
}
181203
}
182204

0 commit comments

Comments
 (0)