Ejemplo n.º 1
0
        protected virtual async Task <ProductViewModel> GetProductViewModelAsync(string id, string variantId = null)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(ContextHelper.HandlePreviewMode(() => GetProductViewModelAsync(PreviewModeService.Value.GetProductId()).Result));
            }

            var productViewModel = await ProductService.GetProductViewModelAsync(new GetProductParam
            {
                ProductId   = id,
                CultureInfo = ComposerContext.CultureInfo,
                Scope       = ComposerContext.Scope,
                VariantId   = variantId,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString()
            }).ConfigureAwait(false);


            if (productViewModel == null)
            {
                throw new HttpException(404, "Product Not Found");
            }

            return(productViewModel);
        }