Пример #1
0
        private static ParentCategoryData getParentCat(long CatId)
        {
            var authentication = new n11Api.ServiceReference1.Authentication();
            authentication.appKey = apiAnahtari1; //api anahtarınız
            authentication.appSecret = apiSifresi1;//api şifeniz

            CategoryServicePortClient proxy = new CategoryServicePortClient();
            GetParentCategoryRequest request = new GetParentCategoryRequest();
            request.auth = authentication;
            request.categoryId = CatId;
            GetParentCategoryResponse parentCat = proxy.GetParentCategory(request);
            ParentCategoryData parentCatData = parentCat.category;
            return parentCat.category;
        }
Пример #2
0
        private static ParentCategoryData getParentCat(long CatId)
        {
            var authentication = new n11Api.ServiceReference1.Authentication();

            authentication.appKey    = apiAnahtari1; //api anahtarınız
            authentication.appSecret = apiSifresi1;  //api şifeniz

            CategoryServicePortClient proxy   = new CategoryServicePortClient();
            GetParentCategoryRequest  request = new GetParentCategoryRequest();

            request.auth       = authentication;
            request.categoryId = CatId;
            GetParentCategoryResponse parentCat     = proxy.GetParentCategory(request);
            ParentCategoryData        parentCatData = parentCat.category;

            return(parentCat.category);
        }
Пример #3
0
        private static GetTopLevelCategoriesResponse getTopCat()
        {
            var authentication = new n11Api.ServiceReference1.Authentication();

            authentication.appKey = apiAnahtari1;   //api anahtarınız

            authentication.appSecret = apiSifresi1; //api şifeniz

            CategoryServicePortClient proxy = new CategoryServicePortClient();

            var request = new GetTopLevelCategoriesRequest();

            request.auth = authentication;


            var categories = proxy.GetTopLevelCategories(request);

            return(categories);
        }
Пример #4
0
        private static SubCategoryData[] getSubCat(long CatId)
        {
            var authentication1 = new n11Api.ServiceReference1.Authentication();

            authentication1.appKey    = apiAnahtari1; //api anahtarınız
            authentication1.appSecret = apiSifresi1;  //api şifeniz


            CategoryServicePortClient port = new CategoryServicePortClient();

            GetSubCategoriesRequest getSubbCatt = new GetSubCategoriesRequest();

            getSubbCatt.categoryId = CatId;
            getSubbCatt.auth       = authentication1;
            GetSubCategoriesResponse response = port.GetSubCategories(getSubbCatt);
            var subCategory = response.category;

            return(subCategory);
        }
Пример #5
0
        private List<CategoryModel> getSubCategories(CategoryServicePortClient service, CategoryModel cat)
        {
            Debug.WriteLine("{0}\t{1}\t{2}\t{3}", categoryCount, cat.ID, cat.Parent == null ? 0 : cat.Parent.ID, cat.Name);
            categoryCount++;

            var response = service.GetSubCategories(new GetSubCategoriesRequest { categoryId = cat.ID });
            if (response.result.status != "success")
            {
                Debug.WriteLine("Kategori bulunamadı: {0} - {1}", cat.ID, cat.ToString());
                return new List<CategoryModel>();
            }
            if (response.category == null || response.category.Length == 0)
                return new List<CategoryModel>();
            var list = response.category[0].subCategoryList;
            if (list == null)
            {
                // En alt seviye
                //var attResponse = service.GetCategoryAttributes(new GetCategoryAttributesRequest
                //                                                {
                //                                                    categoryId = cat.ID
                //                                                });
                //cat.attributes = attResponse.category.attributeList
                //                                .Select(x => new AttributeModel
                //                                {
                //                                    id = x.id,
                //                                    name = x.name,
                //                                    values = x.valueList.Select(y => new KeyValuePair<long, string>(y.id, y.name)).ToList()
                //                                })
                //                                .ToList();

                var obj = callGet("https://api.n11.com/rest/secure/category/getCategoryAttributes.json",
                                    new[] {"id"},
                                    new[] {cat.ID.ToString()});
                var attArr = obj["response"]["data"]["category"]["attributeList"] as JArray;
                if (attArr == null)
                    cat.Attributes = new List<AttributeModel>();
                else
                    cat.Attributes = attArr.Select(x => new AttributeModel
                                        {
                                            id = (long)x["id"],
                                            name = (string)x["name"],
                                            inputMethod = (string)x["inputMethod"],
                                            mandatory = (bool)x["mandatory"],
                                            multipleSelect = (bool)x["multipleSelect"],
                                            code = (string)x["code"],
                                            //values = x.valueList.Select(y => new KeyValuePair<long, string>(y.id, y.name)).ToList()
                                            values = ((JArray)x["valueList"]).Select(y => new KeyValuePair<long, string>((long)y["id"], (string)y["name"])).ToList()
                                        })
                                        .ToList();

                return new List<CategoryModel>();
            }

            var subCatList = list.Select(y => new CategoryModel
            {
                ID = y.id,
                Name = y.name,
                Parent = cat,
                Code = y.id.ToString()
            }).ToList();

            subCatList.ForEach(y => y.Children = getSubCategories(service, y));

            return subCatList;
        }
Пример #6
0
        private static SubCategoryData[] getSubCat(long CatId)
        {
            var authentication1 = new n11Api.ServiceReference1.Authentication();
            authentication1.appKey = apiAnahtari1; //api anahtarınız
            authentication1.appSecret = apiSifresi1;//api şifeniz

            CategoryServicePortClient port = new CategoryServicePortClient();

            GetSubCategoriesRequest getSubbCatt = new GetSubCategoriesRequest();
            getSubbCatt.categoryId = CatId;
            getSubbCatt.auth = authentication1;
            GetSubCategoriesResponse response = port.GetSubCategories(getSubbCatt);
            var subCategory = response.category;
            return subCategory;
        }
Пример #7
0
        private static GetTopLevelCategoriesResponse getTopCat()
        {
            var authentication = new n11Api.ServiceReference1.Authentication();

            authentication.appKey = apiAnahtari1;  //api anahtarınız

            authentication.appSecret = apiSifresi1;//api şifeniz

            CategoryServicePortClient proxy = new CategoryServicePortClient();

            var request = new GetTopLevelCategoriesRequest();
            request.auth = authentication;

            var categories = proxy.GetTopLevelCategories(request);

            return categories;
        }