Last active
August 29, 2015 14:00
-
-
Save codyherring/bd2e0555d75f2df1ce6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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