private MP_EbayAmazonCategory[] GetAndSaveAmazonProcuctCategory( IDatabaseCustomerMarketPlace databaseCustomerMarketPlace, AmazonProductsRequestInfoBySellerSku requestInfo, ActionAccessType access, RequestsCounterData requestCounter, ElapsedTimeInfo elapsedTimeInfo ) { MP_EbayAmazonCategory[] categories = null; AmazonProductItemBase productItem = null; try { productItem = ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds( elapsedTimeInfo, databaseCustomerMarketPlace.Id, ElapsedDataMemberType.RetrieveDataFromExternalService, () => AmazonServiceHelper.GetProductCategories(this.connectionInfo, requestInfo, access, requestCounter) ); } catch (MarketplaceWebServiceProductsException) { // Product not found or cannot be retrieved. } // try if (productItem != null) { var marketplace = databaseCustomerMarketPlace.Marketplace; categories = Helper.AddAmazonCategories(marketplace, productItem, elapsedTimeInfo, databaseCustomerMarketPlace.Id); } // if return(categories); }
public MP_EbayAmazonCategory[] AddAmazonCategories(IMarketplaceType marketplace, AmazonProductItemBase productItem, ElapsedTimeInfo elapsedTimeInfo, int mpId) { var categories = new List <MP_EbayAmazonCategory>(); foreach (AmazonProductCategory amazonProductCategory in productItem.Categories) { var cat = FindEBayAmazonCategory(marketplace, amazonProductCategory.CategoryId, elapsedTimeInfo, mpId) ?? AddAmazonCategory(marketplace, amazonProductCategory, elapsedTimeInfo, mpId); categories.Add(cat); } _CacheAmazonCategoryByProductKey.TryAdd(productItem.Key, categories.ToArray()); return(categories.ToArray()); }