Exemple #1
0
        public static Product ToWebModel(this VirtoCommerceCatalogModuleWebModelProduct product, Language currentLanguage, Currency currentCurrency, Store store)
        {
            var retVal = new Product();

            retVal.Currency = currentCurrency;
            retVal.Price    = new ProductPrice(currentCurrency);

            retVal.InjectFrom <NullableAndEnumValueInjecter>(product);

            retVal.Sku = product.Code;


            if (product.Properties != null)
            {
                retVal.Properties = product.Properties.Where(x => String.Equals(x.Type, "Product", StringComparison.InvariantCultureIgnoreCase))
                                    .Select(p => p.ToWebModel(currentLanguage))
                                    .ToList();
                retVal.VariationProperties = product.Properties.Where(x => String.Equals(x.Type, "Variation", StringComparison.InvariantCultureIgnoreCase))
                                             .Select(p => p.ToWebModel(currentLanguage))
                                             .ToList();
            }
            if (product.Images != null)
            {
                retVal.Images       = product.Images.Select(i => i.ToWebModel()).ToArray();
                retVal.PrimaryImage = retVal.Images.FirstOrDefault(x => String.Equals(x.Url, product.ImgSrc, StringComparison.InvariantCultureIgnoreCase));
            }

            if (product.Assets != null)
            {
                retVal.Assets = product.Assets.Select(x => x.ToWebModel()).ToList();
            }

            if (product.Variations != null)
            {
                retVal.Variations = product.Variations.Select(v => v.ToWebModel(currentLanguage, currentCurrency, store)).ToList();
            }

            if (product.SeoInfos != null)
            {
                //Select best matched SEO by StoreId and Language
                var bestMatchSeo = product.SeoInfos.FindBestSeoMatch(currentLanguage, store);
                if (bestMatchSeo != null)
                {
                    retVal.SeoInfo = bestMatchSeo.ToWebModel();
                }
            }

            if (product.Reviews != null)
            {
                retVal.Descriptions = product.Reviews.Select(r => new LocalizedString(new Language(r.LanguageCode), r.Content)).ToList();
                retVal.Description  = retVal.Descriptions.Where(x => x.Language.Equals(currentLanguage))
                                      .Select(x => x.Value)
                                      .FirstOrDefault();
            }

            return(retVal);
        }
        public static Product ToWebModel(this VirtoCommerceCatalogModuleWebModelProduct product, Language currentLanguage, Currency currentCurrency)
        {
            var retVal = new Product();

            retVal.Currency = currentCurrency;
            retVal.Price    = new ProductPrice(currentCurrency);

            retVal.InjectFrom(product);

            retVal.Sku = product.Code;

            if (product.Category != null)
            {
                retVal.Category = product.Category.ToWebModel();
            }

            if (product.Properties != null)
            {
                retVal.Properties = product.Properties.Where(x => !String.Equals(x.Type, "Variation", StringComparison.InvariantCultureIgnoreCase))
                                    .Select(p => p.ToWebModel(currentLanguage))
                                    .ToList();
                retVal.VariationProperties = product.Properties.Where(x => String.Equals(x.Type, "Variation", StringComparison.InvariantCultureIgnoreCase))
                                             .Select(p => p.ToWebModel(currentLanguage))
                                             .ToList();
            }
            if (product.Images != null)
            {
                retVal.Images       = product.Images.Select(i => i.ToWebModel()).ToArray();
                retVal.PrimaryImage = retVal.Images.FirstOrDefault(x => String.Equals(x.Url, product.ImgSrc, StringComparison.InvariantCultureIgnoreCase));
            }

            if (product.Assets != null)
            {
                retVal.Assets = product.Assets.Select(x => x.ToWebModel()).ToList();
            }

            if (product.Variations != null)
            {
                retVal.Variations = product.Variations.Select(v => v.ToWebModel(currentLanguage, currentCurrency)).ToList();
            }

            if (product.SeoInfos != null)
            {
                retVal.SeoInfo = product.SeoInfos.Select(s => s.ToWebModel()).FirstOrDefault();
            }

            if (product.Reviews != null)
            {
                retVal.Descriptions = product.Reviews.Select(r => new LocalizedString(new Language(r.LanguageCode), r.Content)).ToList();
                retVal.Description  = retVal.Descriptions.Where(x => x.Language.Equals(currentLanguage))
                                      .Select(x => x.Value)
                                      .FirstOrDefault();
            }

            return(retVal);
        }
Exemple #3
0
        public void When_HasNoSeoRecords_Expect_Null()
        {
            var product = new VirtoCommerceCatalogModuleWebModelProduct
            {
                Category = new VirtoCommerceCatalogModuleWebModelCategory(),
            };

            var result = product.Outlines.GetSeoPath(_store, new Language("en-US"), null);

            Assert.Null(result);
        }
Exemple #4
0
        public void When_HasCategorySeoRecords_Expect_LongPath()
        {
            var product = new VirtoCommerceCatalogModuleWebModelProduct
            {
                Outlines = new List <VirtoCommerceDomainCatalogModelOutline>
                {
                    new VirtoCommerceDomainCatalogModelOutline
                    {
                        Items = new List <VirtoCommerceDomainCatalogModelOutlineItem>
                        {
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Catalog",
                            },
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Category",
                                SeoInfos      = new List <VirtoCommerceDomainCommerceModelSeoInfo>
                                {
                                    new VirtoCommerceDomainCommerceModelSeoInfo {
                                        StoreId = "Store1", LanguageCode = "en-US", SemanticUrl = "category1"
                                    },
                                    new VirtoCommerceDomainCommerceModelSeoInfo {
                                        StoreId = "Store1", LanguageCode = "ru-RU", SemanticUrl = "category2"
                                    },
                                },
                            },
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "CatalogProduct",
                                SeoInfos      = new List <VirtoCommerceDomainCommerceModelSeoInfo>
                                {
                                    new VirtoCommerceDomainCommerceModelSeoInfo {
                                        StoreId = "Store1", LanguageCode = "en-US", SemanticUrl = "product1"
                                    },
                                    new VirtoCommerceDomainCommerceModelSeoInfo {
                                        StoreId = "Store1", LanguageCode = "ru-RU", SemanticUrl = "product2"
                                    },
                                },
                            },
                        },
                    },
                },
            };

            var result = product.Outlines.GetSeoPath(_store, new Language("ru-RU"), null);

            Assert.Equal("category2/product2", result);
        }
        public static Category ToWebModel(this VirtoCommerceCatalogModuleWebModelCategory category, VirtoCommerceCatalogModuleWebModelProduct[] products = null)
        {
            var retVal = new Category();
            retVal.InjectFrom<NullableAndEnumValueInjecter>(category);

            if (category.SeoInfos != null)
                retVal.SeoInfo = category.SeoInfos.Select(s => s.ToWebModel()).FirstOrDefault();

            if (category.Images != null)
            {
                retVal.Images = category.Images.Select(i => i.ToWebModel()).ToArray();
                retVal.PrimaryImage = retVal.Images.FirstOrDefault();
            }


            return retVal;
        }
        public static Category ToWebModel(this VirtoCommerceCatalogModuleWebModelCategory category, Language currentLanguage, Store store, VirtoCommerceCatalogModuleWebModelProduct[] products = null)
        {
            var retVal = new Category();
            retVal.InjectFrom<NullableAndEnumValueInjecter>(category);

            retVal.SeoInfo = category.SeoInfos.GetBestMatchedSeoInfo(store, currentLanguage).ToWebModel();
            retVal.Url = "~/" + category.Outlines.GetSeoPath(store, currentLanguage, "category/" + category.Id);

            if (category.Images != null)
            {
                retVal.Images = category.Images.Select(i => i.ToWebModel()).ToArray();
                retVal.PrimaryImage = retVal.Images.FirstOrDefault();
            }

            if (category.Properties != null)
            {
                retVal.Properties = category.Properties
                    .Where(x => string.Equals(x.Type, "Category", StringComparison.OrdinalIgnoreCase))
                    .Select(p => p.ToWebModel(currentLanguage))
                    .ToList();
            }

            return retVal;
        }
        /// <summary>
        /// Updates the specified product. 
        /// </summary>
        /// <exception cref="VirtoCommerce.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="product">The product.</param>
        /// <returns>Task of ApiResponse</returns>
        public async System.Threading.Tasks.Task<ApiResponse<Object>> CatalogModuleProductsUpdateAsyncWithHttpInfo (VirtoCommerceCatalogModuleWebModelProduct product)
        {
            // verify the required parameter 'product' is set
            if (product == null)
                throw new ApiException(400, "Missing required parameter 'product' when calling CatalogModuleApi->CatalogModuleProductsUpdate");

            var localVarPath = "/api/catalog/products";
            var localVarPathParams = new Dictionary<String, String>();
            var localVarQueryParams = new Dictionary<String, String>();
            var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
            var localVarFormParams = new Dictionary<String, String>();
            var localVarFileParams = new Dictionary<String, FileParameter>();
            Object localVarPostBody = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json", 
                "text/json", 
                "application/xml", 
                "text/xml", 
                "application/x-www-form-urlencoded"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
            if (localVarHttpHeaderAccept != null)
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (product.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(product); // http body (model) parameter
            }
            else
            {
                localVarPostBody = product; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
                Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int) localVarResponse.StatusCode;

            if (localVarStatusCode >= 400 && (localVarStatusCode != 404 || Configuration.ThrowExceptionWhenStatusCodeIs404))
                throw new ApiException (localVarStatusCode, "Error calling CatalogModuleProductsUpdate: " + localVarResponse.Content, localVarResponse.Content);
            else if (localVarStatusCode == 0)
                throw new ApiException (localVarStatusCode, "Error calling CatalogModuleProductsUpdate: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);

            
            return new ApiResponse<Object>(localVarStatusCode,
                localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                null);
        }
Exemple #8
0
        public static Product ToWebModel(this VirtoCommerceCatalogModuleWebModelProduct product, Language currentLanguage, Currency currentCurrency, Store store)
        {
            var retVal = new Product();

            retVal.Currency = currentCurrency;
            retVal.Price    = new ProductPrice(currentCurrency);

            retVal.InjectFrom <NullableAndEnumValueInjecter>(product);

            retVal.Sku = product.Code;


            if (product.Properties != null)
            {
                retVal.Properties = product.Properties
                                    .Where(x => string.Equals(x.Type, "Product", StringComparison.InvariantCultureIgnoreCase))
                                    .Select(p => p.ToWebModel(currentLanguage))
                                    .ToList();

                retVal.VariationProperties = product.Properties
                                             .Where(x => string.Equals(x.Type, "Variation", StringComparison.InvariantCultureIgnoreCase))
                                             .Select(p => p.ToWebModel(currentLanguage))
                                             .ToList();
            }

            if (product.Images != null)
            {
                retVal.Images       = product.Images.Select(i => i.ToWebModel()).ToArray();
                retVal.PrimaryImage = retVal.Images.FirstOrDefault(x => string.Equals(x.Url, product.ImgSrc, StringComparison.InvariantCultureIgnoreCase));
            }

            if (product.Assets != null)
            {
                retVal.Assets = product.Assets.Select(x => x.ToWebModel()).ToList();
            }

            if (product.Variations != null)
            {
                retVal.Variations = product.Variations.Select(v => v.ToWebModel(currentLanguage, currentCurrency, store)).ToList();
            }

            if (!product.Associations.IsNullOrEmpty())
            {
                retVal.Associations.AddRange(product.Associations.Select(x => x.ToWebModel()));
            }

            retVal.SeoInfo = product.SeoInfos.GetBestMatchedSeoInfo(store, currentLanguage).ToWebModel();
            retVal.Url     = "~/" + product.Outlines.GetSeoPath(store, currentLanguage, "product/" + product.Id);

            if (product.Reviews != null)
            {
                retVal.Descriptions = product.Reviews.Select(r => new EditorialReview
                {
                    Language   = new Language(r.LanguageCode),
                    ReviewType = r.ReviewType,
                    Value      = r.Content
                }).Where(x => x.Language.Equals(currentLanguage)).ToList();
                retVal.Description = retVal.Descriptions.FindWithLanguage(currentLanguage, x => x.Value, null);
            }

            return(retVal);
        }
 /// <summary>
 /// Updates the specified product. 
 /// </summary>
 /// <exception cref="VirtoCommerce.Client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="product">The product.</param>
 /// <returns></returns>
 public void CatalogModuleProductsUpdate (VirtoCommerceCatalogModuleWebModelProduct product)
 {
      CatalogModuleProductsUpdateWithHttpInfo(product);
 }
        /// <summary>
        /// Updates the specified product. 
        /// </summary>
        /// <exception cref="VirtoCommerce.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="product">The product.</param>
        /// <returns>Task of void</returns>
        public async System.Threading.Tasks.Task CatalogModuleProductsUpdateAsync (VirtoCommerceCatalogModuleWebModelProduct product)
        {
             await CatalogModuleProductsUpdateAsyncWithHttpInfo(product);

        }
Exemple #11
0
        public void When_MissingAnyParentSeoRecord_Expect_Null()
        {
            var product = new VirtoCommerceCatalogModuleWebModelProduct
            {
                Outlines = new List <VirtoCommerceDomainCatalogModelOutline>
                {
                    new VirtoCommerceDomainCatalogModelOutline
                    {
                        Items = new List <VirtoCommerceDomainCatalogModelOutlineItem>
                        {
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Catalog",
                            },
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Category",
                                SeoInfos      = new List <VirtoCommerceDomainCommerceModelSeoInfo>(),
                            },
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Category",
                                SeoInfos      = new List <VirtoCommerceDomainCommerceModelSeoInfo>
                                {
                                    new VirtoCommerceDomainCommerceModelSeoInfo {
                                        StoreId = "Store1", LanguageCode = "en-US", SemanticUrl = "parent1"
                                    },
                                    new VirtoCommerceDomainCommerceModelSeoInfo {
                                        StoreId = "Store1", LanguageCode = "ru-RU", SemanticUrl = "parent2"
                                    },
                                }
                            },
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Category",
                                SeoInfos      = new List <VirtoCommerceDomainCommerceModelSeoInfo>
                                {
                                    new VirtoCommerceDomainCommerceModelSeoInfo {
                                        StoreId = "Store1", LanguageCode = "en-US", SemanticUrl = "category1"
                                    },
                                    new VirtoCommerceDomainCommerceModelSeoInfo {
                                        StoreId = "Store1", LanguageCode = "ru-RU", SemanticUrl = "category2"
                                    },
                                },
                            },
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Category",
                                SeoInfos      = new List <VirtoCommerceDomainCommerceModelSeoInfo>
                                {
                                    new VirtoCommerceDomainCommerceModelSeoInfo {
                                        StoreId = "Store1", LanguageCode = "en-US", SemanticUrl = "product1"
                                    },
                                    new VirtoCommerceDomainCommerceModelSeoInfo {
                                        StoreId = "Store1", LanguageCode = "ru-RU", SemanticUrl = "product2"
                                    },
                                },
                            },
                        },
                    },
                },
            };

            var result = product.Outlines.GetSeoPath(_store, new Language("ru-RU"), null);

            Assert.Null(result);
        }
        /// <summary>
        /// Updates the specified product. 
        /// </summary>
        /// <param name="product">The product.</param>
        /// <returns>Task of ApiResponse</returns>
        public async System.Threading.Tasks.Task<ApiResponse<Object>> CatalogModuleProductsUpdateAsyncWithHttpInfo (VirtoCommerceCatalogModuleWebModelProduct product)
        {
            // verify the required parameter 'product' is set
            if (product == null) throw new ApiException(400, "Missing required parameter 'product' when calling CatalogModuleProductsUpdate");
            
    
            var path_ = "/api/catalog/products";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            String postBody = null;

            // to determine the Accept header
            String[] http_header_accepts = new String[] {
                
            };
            String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts);
            if (http_header_accept != null)
                headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts));

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            
            
            
            
            postBody = Configuration.ApiClient.Serialize(product); // http body (model) parameter
            

            

            // make the HTTP request
            IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);

            int statusCode = (int) response.StatusCode;
 
            if (statusCode >= 400)
                throw new ApiException (statusCode, "Error calling CatalogModuleProductsUpdate: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException (statusCode, "Error calling CatalogModuleProductsUpdate: " + response.ErrorMessage, response.ErrorMessage);

            
            return new ApiResponse<Object>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                null);
        }
Exemple #13
0
        public void When_HasNoSeoRecords_Expect_Null()
        {
            var product = new VirtoCommerceCatalogModuleWebModelProduct
            {
                Category = new VirtoCommerceCatalogModuleWebModelCategory(),
            };

            var result = product.Outlines.GetSeoPath(_store, new Language("en-US"), null);
            Assert.Null(result);
        }
Exemple #14
0
        public void When_HasParentCategorySeoRecords_Expect_LongPath()
        {
            var product = new VirtoCommerceCatalogModuleWebModelProduct
            {
                Outlines = new List<VirtoCommerceDomainCatalogModelOutline>
                {
                    new VirtoCommerceDomainCatalogModelOutline
                    {
                        Items = new List<VirtoCommerceDomainCatalogModelOutlineItem>
                        {
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Catalog",
                            },
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Category",
                                SeoInfos = new List<VirtoCommerceDomainCommerceModelSeoInfo>
                                {
                                    new VirtoCommerceDomainCommerceModelSeoInfo { StoreId = "Store1", LanguageCode = "en-US", SemanticUrl = "grandparent1" },
                                    new VirtoCommerceDomainCommerceModelSeoInfo { StoreId = "Store1", LanguageCode = "ru-RU", SemanticUrl = "grandparent2" },
                                }
                            },
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Category",
                                SeoInfos = new List<VirtoCommerceDomainCommerceModelSeoInfo>
                                {
                                    new VirtoCommerceDomainCommerceModelSeoInfo { StoreId = "Store1", LanguageCode = "en-US", SemanticUrl = "parent1" },
                                    new VirtoCommerceDomainCommerceModelSeoInfo { StoreId = "Store1", LanguageCode = "ru-RU", SemanticUrl = "parent2" },
                                }
                            },
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Category",
                                SeoInfos = new List<VirtoCommerceDomainCommerceModelSeoInfo>
                                {
                                    new VirtoCommerceDomainCommerceModelSeoInfo { StoreId = "Store1", LanguageCode = "en-US", SemanticUrl = "category1" },
                                    new VirtoCommerceDomainCommerceModelSeoInfo { StoreId = "Store1", LanguageCode = "ru-RU", SemanticUrl = "category2" },
                                },
                            },
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "CatalogProduct",
                                SeoInfos = new List<VirtoCommerceDomainCommerceModelSeoInfo>
                                {
                                    new VirtoCommerceDomainCommerceModelSeoInfo { StoreId = "Store1", LanguageCode = "en-US", SemanticUrl = "product1" },
                                    new VirtoCommerceDomainCommerceModelSeoInfo { StoreId = "Store1", LanguageCode = "ru-RU", SemanticUrl = "product2" },
                                },
                            },
                        },
                    },
                },
            };

            var result = product.Outlines.GetSeoPath(_store, new Language("ru-RU"), null);
            Assert.Equal("grandparent2/parent2/category2/product2", result);
        }
 public IHttpActionResult Update(VirtoCommerceCatalogModuleWebModelProduct product)
 {
     _productClient.CatalogModuleProductsUpdate(product);
     return StatusCode(HttpStatusCode.NoContent);
 }
Exemple #16
0
        /// <summary>
        /// Updates the specified product. 
        /// </summary>
        /// <param name="product">The product.</param> 
        /// <returns>ApiResponse of Object(void)</returns>
        public ApiResponse<Object> CatalogModuleProductsUpdateWithHttpInfo (VirtoCommerceCatalogModuleWebModelProduct product)
        {
            
            // verify the required parameter 'product' is set
            if (product == null)
                throw new ApiException(400, "Missing required parameter 'product' when calling CatalogModuleApi->CatalogModuleProductsUpdate");
            
    
            var path_ = "/api/catalog/products";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            Object postBody = null;

            // to determine the Content-Type header
            String[] httpContentTypes = new String[] {
                "application/json", "text/json", "application/x-www-form-urlencoded"
            };
            String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);

            // to determine the Accept header
            String[] httpHeaderAccepts = new String[] {
                
            };
            String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
            if (httpHeaderAccept != null)
                headerParams.Add("Accept", httpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            
            
            
            
            if (product.GetType() != typeof(byte[]))
            {
                postBody = Configuration.ApiClient.Serialize(product); // http body (model) parameter
            }
            else
            {
                postBody = product; // byte array
            }

            
    
            // make the HTTP request
            IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, 
                Method.POST, queryParams, postBody, headerParams, formParams, fileParams,
                pathParams, httpContentType);

            int statusCode = (int) response.StatusCode;
    
            if (statusCode >= 400 && (statusCode != 404 || Configuration.ThrowExceptionWhenStatusCodeIs404))
                throw new ApiException (statusCode, "Error calling CatalogModuleProductsUpdate: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException (statusCode, "Error calling CatalogModuleProductsUpdate: " + response.ErrorMessage, response.ErrorMessage);
    
            
            return new ApiResponse<Object>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                null);
        }
Exemple #17
0
        public void When_MissingAnyParentSeoRecord_Expect_Null()
        {
            var product = new VirtoCommerceCatalogModuleWebModelProduct
            {
                Outlines = new List<VirtoCommerceDomainCatalogModelOutline>
                {
                    new VirtoCommerceDomainCatalogModelOutline
                    {
                        Items = new List<VirtoCommerceDomainCatalogModelOutlineItem>
                        {
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Catalog",
                            },
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Category",
                                SeoInfos = new List<VirtoCommerceDomainCommerceModelSeoInfo>(),
                            },
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Category",
                                SeoInfos = new List<VirtoCommerceDomainCommerceModelSeoInfo>
                                {
                                    new VirtoCommerceDomainCommerceModelSeoInfo { StoreId = "Store1", LanguageCode = "en-US", SemanticUrl = "parent1" },
                                    new VirtoCommerceDomainCommerceModelSeoInfo { StoreId = "Store1", LanguageCode = "ru-RU", SemanticUrl = "parent2" },
                                }
                            },
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Category",
                                SeoInfos = new List<VirtoCommerceDomainCommerceModelSeoInfo>
                                {
                                    new VirtoCommerceDomainCommerceModelSeoInfo { StoreId = "Store1", LanguageCode = "en-US", SemanticUrl = "category1" },
                                    new VirtoCommerceDomainCommerceModelSeoInfo { StoreId = "Store1", LanguageCode = "ru-RU", SemanticUrl = "category2" },
                                },
                            },
                            new VirtoCommerceDomainCatalogModelOutlineItem
                            {
                                SeoObjectType = "Category",
                                SeoInfos = new List<VirtoCommerceDomainCommerceModelSeoInfo>
                                {
                                    new VirtoCommerceDomainCommerceModelSeoInfo { StoreId = "Store1", LanguageCode = "en-US", SemanticUrl = "product1" },
                                    new VirtoCommerceDomainCommerceModelSeoInfo { StoreId = "Store1", LanguageCode = "ru-RU", SemanticUrl = "product2" },
                                },
                            },
                        },
                    },
                },
            };

            var result = product.Outlines.GetSeoPath(_store, new Language("ru-RU"), null);
            Assert.Null(result);
        }