Skip to content

Instantly share code, notes, and snippets.

@codyherring
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codyherring/bd2e0555d75f2df1ce6e to your computer and use it in GitHub Desktop.
Save codyherring/bd2e0555d75f2df1ce6e to your computer and use it in GitHub Desktop.
private MarketplaceCategory ParseMarketplaceCategory(XElement categoryXml)
{
string industryName = (string)categoryXml.Element("IndustryName");
string industryCode = (string)categoryXml.Element("IndustryCode");
string subcategoryName = (string)categoryXml.Element("SubcategoryName");
string[] splitSubcategoryName = NeweggUtility.SplitCategoryName(subcategoryName);
string marketplaceCategoryName = string.Empty;
//if the length is greater than 1, the IndustryCode might be in the SubcategoryName
//look at the first element to see if it's in the dictionary
if(splitSubcategoryName.Length > 1)
{
//if the code is in the dictionary, replace the code with the industry name
if(splitSubcategoryName[0] == industryCode)
{
splitSubcategoryName[0] = industryName;
marketplaceCategoryName = string.Join(" > ", splitSubcategoryName);
}
else
{
marketplaceCategoryName = industryName + string.Join(" > ", splitSubcategoryName);
}
}
MarketplaceCategory mc = new MarketplaceCategory();
mc.MarketplaceCategoryName = marketplaceCategoryName;
mc.MarketplaceName = NEWEGG;
mc.IsActive = (bool)categoryXml.Element("Enabled");
mc.MarketplaceCategoryName = marketplaceCategoryName;
mc.MarketplaceCategoryCode = (string)categoryXml.Element("SubcategoryID");
return mc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment