コード例 #1
0
        //TODO: Would it be possible to add cache here too without too much problem?
        //TODO: Because it is called 3 times when you retrieve the Cart
        protected virtual async Task <CartViewModel> CreateCartViewModelAsync(CreateCartViewModelParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            if (param.Cart == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Cart"), "param");
            }
            if (string.IsNullOrWhiteSpace(param.BaseUrl))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("BaseUrl"), "param");
            }

            param.ProductImageInfo = new ProductImageInfo
            {
                ImageUrls = await ImageService.GetImageUrlsAsync(param.Cart.GetLineItems()).ConfigureAwait(false),
            };

            var methodDisplayNames = await LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam
            {
                CultureInfo = param.CultureInfo,
                LookupType  = LookupType.Order,
                LookupName  = "PaymentMethodType",
            }).ConfigureAwait(false);

            param.PaymentMethodDisplayNames = methodDisplayNames;

            var vm = CartViewModelFactory.CreateCartViewModel(param);

            return(vm);
        }
コード例 #2
0
        protected virtual async Task <CartViewModel> CreateCartViewModelAsync(CreateCartViewModelParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.Cart == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.Cart)), nameof(param));
            }
            if (param.BaseUrl == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.BaseUrl)), nameof(param));
            }

            param.ProductImageInfo = new ProductImageInfo
            {
                ImageUrls = await ImageService.GetImageUrlsAsync(param.Cart.GetLineItems()).ConfigureAwait(false)
            };

            var methodDisplayNames = await LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam
            {
                CultureInfo = param.CultureInfo,
                LookupType  = LookupType.Order,
                LookupName  = "PaymentMethodType",
            });

            param.PaymentMethodDisplayNames = methodDisplayNames;

            var vm = CartViewModelFactory.CreateCartViewModel(param);

            return(vm);
        }
コード例 #3
0
        //TODO: Would it be possible to add cache here too without too much problem?
        //TODO: Because it is called 3 times when you retrieve the Cart
        public virtual async Task <CartViewModel> CreateCartViewModelAsync(CreateCartViewModelParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.Cart == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.Cart)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.BaseUrl))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.BaseUrl)), nameof(param));
            }

            param.ProductImageInfo = new ProductImageInfo
            {
                ImageUrls = await ImageService.GetImageUrlsAsync(param.Cart.GetLineItems()).ConfigureAwait(false),
            };

            var methodDisplayNames = await LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam
            {
                CultureInfo = param.CultureInfo,
                LookupType  = LookupType.Order,
                LookupName  = "PaymentMethodType",
            }).ConfigureAwait(false);

            param.PaymentMethodDisplayNames = methodDisplayNames;

            var vm = CartViewModelFactory.CreateCartViewModel(param);

            if (CartConfiguration.GroupCartItemsByPrimaryCategory)
            {
                vm.GroupedLineItemDetailViewModels = await GetGroupedLineItems(vm, param).ConfigureAwait(false);
            }

            return(vm);
        }
コード例 #4
0
        protected virtual async Task <CartViewModel> CreateCartViewModelAsync(CreateCartViewModelParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.Cart == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.Cart)), nameof(param));
            }
            if (param.BaseUrl == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.BaseUrl)), nameof(param));
            }

            param.ProductImageInfo = new ProductImageInfo
            {
                ImageUrls = await ImageService.GetImageUrlsAsync(param.Cart.GetLineItems()).ConfigureAwait(false)
            };

            var vm = CartViewModelFactory.CreateCartViewModel(param);

            return(vm);
        }
コード例 #5
0
        protected virtual async Task <CartViewModel> CreateCartViewModelAsync(CreateCartViewModelParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            if (param.Cart == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Cart"), "param");
            }
            if (param.BaseUrl == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("BaseUrl"), "param");
            }

            param.ProductImageInfo = new ProductImageInfo
            {
                ImageUrls = await ImageService.GetImageUrlsAsync(param.Cart.GetLineItems()).ConfigureAwait(false)
            };

            var vm = CartViewModelFactory.CreateCartViewModel(param);

            return(vm);
        }