private RelatedProductsViewModel CreateRelatedProductsViewModel(string id, string merchandiseTypes, string headingText, int maxItems, bool displaySameCategoryProducts, bool displayPrices, bool displayAddToCart, string backgroundStyle) { var param = new GetProductIdentifiersParam { CultureInfo = ComposerContext.CultureInfo, ProductId = id, Scope = ComposerContext.Scope, MerchandiseTypes = merchandiseTypes.Split(','), FallbackOnSameCategoriesProduct = displaySameCategoryProducts, MaxItems = maxItems }; var relatedProductsViewModel = RelatedProductViewService.GetProductIdsAsync(param).Result; relatedProductsViewModel.Context["DisplayAddToCart"] = displayAddToCart; relatedProductsViewModel.Context["DisplayPrices"] = displayPrices; relatedProductsViewModel.Context["HeadingComponentText"] = headingText; if (!string.IsNullOrWhiteSpace(backgroundStyle)) { relatedProductsViewModel.Context["BackgroundStyle"] = backgroundStyle; } return(relatedProductsViewModel);; }
public virtual async Task <IHttpActionResult> RelatedProducts(IEnumerable <ProductIdentifier> relatedProductIdentifiers) //TODO: Make a ViewModel for this. { var param = new GetRelatedProductsParam { ProductIds = relatedProductIdentifiers, CultureInfo = ComposerContext.CultureInfo, Scope = ComposerContext.Scope, BaseUrl = RequestUtils.GetBaseUrl(Request) }; var vm = await RelatedProductViewService.GetRelatedProductsAsync(param); return(Ok(vm)); }