Ejemplo n.º 1
0
        protected virtual async Task <StoreViewModel> GetStoreViewModelAsync(string storeNumber)
        {
            if (string.IsNullOrWhiteSpace(storeNumber))
            {
                return(ContextHelper.HandlePreviewMode(() => GetStoreViewModelAsync(PreviewModeService.Value.GetStoreNumber()).Result));
            }

            var vm = await StoreViewService.GetStoreViewModelAsync(new GetStoreByNumberParam
            {
                StoreNumber = storeNumber,
                CultureInfo = ComposerContext.CultureInfo,
                Scope       = ComposerContext.Scope,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString()
            }).ConfigureAwait(false);

            return(vm);
        }
        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);

            return(productViewModel);
        }