public void SetStoreCategories() { // Skip if the user is not store enabled. if (TestData.Store == null) return; SetStoreCategoriesCall api = new SetStoreCategoriesCall(this.apiContext); // Build the StoreType object. StoreType st = new StoreType(); st.Description = TestData.Store.Description; st.Logo = TestData.Store.Logo; st.MerchDisplay = TestData.Store.MerchDisplay; st.Name = TestData.Store.Name; api.Action = StoreCategoryUpdateActionCodeType.Add; api.DestinationParentCategoryID = 1234; api.ItemDestinationCategoryID = 4321; StoreCustomCategoryTypeCollection catArray = new StoreCustomCategoryTypeCollection(); api.StoreCategoryList = catArray; StoreCustomCategoryType cat = new StoreCustomCategoryType(); catArray.Add(cat); cat.CategoryID = 102; cat.Name = "TestStoreCategory"; // Make API call. ApiException gotException = null; // Negative test. try { api.Execute(); } catch (ApiException ex) { gotException = ex; } Assert.IsNotNull(gotException); }
public void SetStoreCategories() { // Skip if the user is not store enabled. if (TestData.Store == null) { return; } SetStoreCategoriesCall api = new SetStoreCategoriesCall(this.apiContext); // Build the StoreType object. StoreType st = new StoreType(); st.Description = TestData.Store.Description; st.Logo = TestData.Store.Logo; st.MerchDisplay = TestData.Store.MerchDisplay; st.Name = TestData.Store.Name; api.Action = StoreCategoryUpdateActionCodeType.Add; api.DestinationParentCategoryID = 1234; api.ItemDestinationCategoryID = 4321; StoreCustomCategoryTypeCollection catArray = new StoreCustomCategoryTypeCollection(); api.StoreCategoryList = catArray; StoreCustomCategoryType cat = new StoreCustomCategoryType(); catArray.Add(cat); cat.CategoryID = 102; cat.Name = "TestStoreCategory"; // Make API call. ApiException gotException = null; // Negative test. try { api.Execute(); } catch (ApiException ex) { gotException = ex; } Assert.IsNotNull(gotException); }
private static void GeteBayChildCategoriesRoot(StoreCustomCategoryType cat, CategoryItm catItm, int pId, Dictionary<string, CategoryDef> catDefIdLst, CategoryContainer container) { //continue the recursion for each of the child categories foreach (StoreCustomCategoryType childcat in cat.ChildCategory) { //get the category name, ID and whether it is a leaf int parentId = pId; long id = cat.CategoryID; string name = cat.Name; bool leaf = (cat.ChildCategory.Count == 0); Console.WriteLine("id = " + id + " name = " + name + " leaf= " + leaf); CategoryDef catDef = new CategoryDef(childcat.Name, childcat.CategoryID.ToString(), cat.CategoryID.ToString()); try { catDefIdLst.Add(childcat.CategoryID.ToString(), catDef); } catch { } string catName = name; // LoadNode(parent category id, container) -> find all cats call -> LoadNode(parent category id, container) //string pId = parentCategory.Key; CategoryItm catItm2 = new CategoryItm(childcat.CategoryID.ToString(), childcat.Name, catItm); if (!container.IdLinkList.ContainsKey(childcat.CategoryID.ToString())) { container.IdLinkList.Add(childcat.CategoryID.ToString(), catItm2); } catItm.Items.Add(catItm2); GeteBayChildCategoriesRoot(childcat, catItm2, (int)id, catDefIdLst, container); } }
public static CategoryContainer BuildCategoryFromeBay(bool storeCatBuild = false) { if (storeCatBuild == false) { CategoryContainer container = new CategoryContainer(); apiContext = AppSettingHelper.GetApiContext(); apiContext.ApiLogManager = new ApiLogManager(); apiContext.ApiLogManager.ApiLoggerList.Add(new FileLogger("log.txt", true, true, true)); apiContext.ApiLogManager.EnableLogging = true; apiContext.Site = SiteCodeType.US; GetCategoriesCall catCall = new GetCategoriesCall(apiContext) { EnableCompression = true, ViewAllNodes = true }; catCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); catCall.GetCategories(); Dictionary<string, CategoryDef> catIdCMLst = new Dictionary<string, CategoryDef>(); foreach (CategoryType category in catCall.CategoryList) { int categoryId = Int32.Parse(category.CategoryID); int? parentId = Int32.Parse(category.CategoryParentID[0]); if (parentId == categoryId) { parentId = null; } if (parentId == null) { catIdCMLst.Add(category.CategoryID, new CategoryDef(category.CategoryName, category.CategoryID)); } else { catIdCMLst.Add(category.CategoryID, new CategoryDef(category.CategoryName, category.CategoryID, parentId.ToString())); } } // Lets get all parent categories so we can build down the tree. var parentQuery = from parentCategory in catIdCMLst where parentCategory.Value.ParentId == "" select parentCategory; foreach (var parentCategory in parentQuery) { string catName = parentCategory.Value.CategoryName; // LoadNode(parent category id, container) -> find all cats call -> LoadNode(parent category id, container) string pId = parentCategory.Key; CategoryItm catItm = new CategoryItm(pId, catName); container.IdLinkList.Add(pId, catItm); container.Items.Add(catItm); LoadeBayNode(pId, catItm, catIdCMLst, container); } return container; } else { CategoryContainer container = new CategoryContainer(); apiContext = AppSettingHelper.GetApiContext(); apiContext.ApiLogManager = new ApiLogManager(); apiContext.ApiLogManager.ApiLoggerList.Add(new FileLogger("log.txt", true, true, true)); apiContext.ApiLogManager.EnableLogging = true; apiContext.Site = SiteCodeType.US; GetStoreCall getStoreCall = new GetStoreCall(apiContext) { EnableCompression = true }; getStoreCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); getStoreCall.CategoryStructureOnly = true; getStoreCall.Execute(); StoreCustomCategoryType cType = new StoreCustomCategoryType(); Dictionary<string, CategoryDef> catIdCMLst = new Dictionary<string, CategoryDef>(); foreach (StoreCustomCategoryType category in getStoreCall.Store.CustomCategories) { CategoryItm catItm = new CategoryItm(category.CategoryID.ToString(), category.Name); container.IdLinkList.Add(category.CategoryID.ToString(), catItm); container.Items.Add(catItm); GeteBayChildCategoriesRoot(category, catItm, (int)category.CategoryID, catIdCMLst, container); //container.Items.Add(catItm); } // Lets get all parent categories so we can build down the tree. /*var parentQuery = from parentCategory in catIdCMLst select parentCategory; foreach (var parentCategory in parentQuery) { string catName = parentCategory.Value.CategoryName; // LoadNode(parent category id, container) -> find all cats call -> LoadNode(parent category id, container) string pId = parentCategory.Key; CategoryItm catItm = new CategoryItm(pId, catName); container.IdLinkList.Add(pId, catItm); container.Items.Add(catItm); LoadeBayNode(pId, catItm, catIdCMLst, container); }*/ return container; } //} //catch //{ // return null; //} }