示例#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
        public async virtual Task <ShippingMethodTypesViewModel> GetShippingMethodTypesAsync(GetShippingMethodsParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }

            var shippingMethods = await GetFulfillmentMethods(param).ConfigureAwait(false);

            if (shippingMethods == null)
            {
                return(null);
            }

            var shippingMethodTypeViewModels = shippingMethods
                                               .Select(sm => CartViewModelFactory.GetShippingMethodViewModel(sm, param.CultureInfo))
                                               .Where(FilterShippingMethodView)
                                               .GroupBy(sm => sm.FulfillmentMethodType)
                                               .Select(type => CartViewModelFactory.GetShippingMethodTypeViewModel(type.Key, type.ToList(), param.CultureInfo))
                                               .OrderBy(OrderShippingMethodTypeView)
                                               .ToList();

            return(new ShippingMethodTypesViewModel
            {
                ShippingMethodTypes = shippingMethodTypeViewModels
            });
        }
示例#3
0
        public virtual async Task <CustomerPaymentMethodsViewModel> GetCustomerPaymentMethodsViewModelAsync(GetCustomerPaymentMethodListViewModelParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }

            var allMethods = await PaymentRepository.GetPaymentMethodsAsync(new GetPaymentMethodsParam
            {
                CartName      = CartConfiguration.ShoppingCartName,
                CultureInfo   = param.CultureInfo,
                CustomerId    = param.CustomerId,
                Scope         = param.ScopeId,
                ProviderNames = param.ProviderNames
            }).ConfigureAwait(false);

            var savedCreditCardVm = allMethods.Where(m => m.Type == PaymentMethodType.SavedCreditCard)
                                    .Select(m => CartViewModelFactory.MapSavedCreditCard(m, param.CultureInfo)).ToList();

            var isUsedInRecurringTasks = savedCreditCardVm.Select(vm => IsSavedCardUsedInRecurringOrders(vm, param.CultureInfo, param.CustomerId, param.ScopeId)).ToList();
            await Task.WhenAll(isUsedInRecurringTasks).ConfigureAwait(false);

            return(new CustomerPaymentMethodsViewModel
            {
                SavedCreditCards = savedCreditCardVm
                                   //AddWalletUrl
            });
        }
示例#4
0
        protected virtual AddressViewModel GetBillingAddressViewModel(CreateOrderDetailViewModelParam param)
        {
            var validPayment = param.Order.Cart.Payments.Where(x => !x.IsVoided()).FirstOrDefault();
            var payment      = validPayment ?? param.Order.Cart.Payments.FirstOrDefault();

            return(payment == null ? null : CartViewModelFactory.GetAddressViewModel(payment.BillingAddress, param.CultureInfo));
        }
示例#5
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);
        }
        public DefaultCartController(
            ICartService cartService,
            IOrderRepository orderRepository,
            ICommerceTrackingService recommendationService,
            CartViewModelFactory cartViewModelFactory,
            IContentLoader contentLoader,
            IContentRouteHelper contentRouteHelper,
            ReferenceConverter referenceConverter,
            IQuickOrderService quickOrderService,
            ICustomerService customerService,
            ShipmentViewModelFactory shipmentViewModelFactory,
            CheckoutService checkoutService,
            IOrderGroupCalculator orderGroupCalculator,
            CartItemViewModelFactory cartItemViewModelFactory,
            IProductService productService,
            LanguageResolver languageResolver)

        {
            _cartService              = cartService;
            _orderRepository          = orderRepository;
            _recommendationService    = recommendationService;
            _cartViewModelFactory     = cartViewModelFactory;
            _contentLoader            = contentLoader;
            _contentRouteHelper       = contentRouteHelper;
            _referenceConverter       = referenceConverter;
            _quickOrderService        = quickOrderService;
            _customerService          = customerService;
            _shipmentViewModelFactory = shipmentViewModelFactory;
            _checkoutService          = checkoutService;
            _orderGroupCalculator     = orderGroupCalculator;
            _cartItemViewModelFactory = cartItemViewModelFactory;
            _productService           = productService;
            _languageResolver         = languageResolver;
        }
示例#7
0
        /// <summary>
        /// Estimates the shipping method. Does not save the cart.
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public virtual async Task <ShippingMethodViewModel> EstimateShippingAsync(EstimateShippingParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("CultureInfo"), "param");
            }
            if (param.Cart == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Cart"), "param");
            }

            var shippingMethods = await GetShippingMethodsForShippingEstimationAsync(param);

            var selectedMethod = GetCheapestShippingMethodViewModel(shippingMethods);
            var firstShipment  = GetShipment(param.Cart);

            if (param.ForceUpdate || firstShipment.FulfillmentMethod == null)
            {
                firstShipment.FulfillmentMethod = selectedMethod;
            }

            var vm = CartViewModelFactory.GetShippingMethodViewModel(firstShipment.FulfillmentMethod, param.CultureInfo);

            return(vm);
        }
示例#8
0
 public WishListController(
     IContentLoader contentLoader,
     ICartService cartService,
     IOrderRepository orderRepository,
     ICommerceTrackingService recommendationService,
     CartViewModelFactory cartViewModelFactory,
     IQuickOrderService quickOrderService,
     ReferenceConverter referenceConverter,
     ICustomerService customerService,
     IUrlResolver urlResolver,
     IRelationRepository relationRepository,
     LanguageResolver languageResolver,
     ICurrentMarket currentMarket,
     FilterPublished filterPublished,
     ISettingsService settingsService)
 {
     _contentLoader        = contentLoader;
     _cartService          = cartService;
     _orderRepository      = orderRepository;
     _trackingService      = recommendationService;
     _cartViewModelFactory = cartViewModelFactory;
     _quickOrderService    = quickOrderService;
     _referenceConverter   = referenceConverter;
     _customerService      = customerService;
     _urlResolver          = urlResolver;
     _relationRepository   = relationRepository;
     _languageResolver     = languageResolver;
     _currentMarket        = currentMarket;
     _filterPublished      = filterPublished;
     _settingsService      = settingsService;
 }
示例#9
0
        protected virtual async Task <List <IPaymentMethodViewModel> > MapPaymentMethodsViewModel(IEnumerable <PaymentMethod> paymentMethods,
                                                                                                  CultureInfo cultureInfo,
                                                                                                  Guid customerId,
                                                                                                  string scope)
        {
            var paymentMethodViewModels = new List <IPaymentMethodViewModel>();

            foreach (var method in paymentMethods.Where(x => x.Enabled))
            {
                var methodDisplayNames = await LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam
                {
                    CultureInfo = cultureInfo,
                    LookupType  = LookupType.Order,
                    LookupName  = "PaymentMethodType",
                }).ConfigureAwait(false);

                var methodViewModel = CartViewModelFactory.GetPaymentMethodViewModel(method, methodDisplayNames, cultureInfo);
                if (methodViewModel != null)
                {
                    var paymentProvider = ObtainPaymentProvider(methodViewModel.PaymentProviderName);
                    methodViewModel.PaymentProviderType = paymentProvider?.ProviderType;

                    await IsSavedCardUsedInRecurringOrders(methodViewModel, cultureInfo, customerId, scope);

                    paymentMethodViewModels.Add(methodViewModel);
                }
            }

            return(paymentMethodViewModels.ToList());
        }
示例#10
0
 public DemoHeaderViewModelFactory(LocalizationService localizationService,
                                   IAddressBookService addressBookService,
                                   ICustomerService customerService,
                                   CartViewModelFactory cartViewModelFactory,
                                   IUrlResolver urlResolver,
                                   IMarketService marketService,
                                   ICurrentMarket currentMarket,
                                   IBookmarksService bookmarksService,
                                   ICartService cartService,
                                   CustomerContext customerContext,
                                   IContentCacheKeyCreator contentCacheKeyCreator,
                                   IContentLoader contentLoader,
                                   CmsHeaderViewModelFactory cmsHeaderViewModelFactory) :
     base(localizationService,
          addressBookService,
          customerService,
          cartViewModelFactory,
          urlResolver,
          marketService,
          currentMarket,
          bookmarksService,
          cartService,
          contentCacheKeyCreator,
          contentLoader)
 {
     _customerService           = customerService;
     _customerContext           = customerContext;
     _cmsHeaderViewModelFactory = cmsHeaderViewModelFactory;
 }
        public CartViewModelFactoryTests()
        {
            _cart = new FakeCart(new MarketImpl(MarketId.Default), Currency.USD);
            _cart.Forms.Single().Shipments.Single().LineItems.Add(new InMemoryLineItem {
                Quantity = 1, PlacedPrice = 105, LineItemDiscountAmount = 5
            });

            _startPage = new StartPage()
            {
                CheckoutPage = new ContentReference(1), WishListPage = new ContentReference(1)
            };
            var contentLoaderMock = new Mock <IContentLoader>();

            contentLoaderMock.Setup(x => x.Get <StartPage>(It.IsAny <ContentReference>())).Returns(_startPage);
            var languageResolverMock = new Mock <LanguageResolver>();

            languageResolverMock.Setup(x => x.GetPreferredCulture()).Returns(CultureInfo.InvariantCulture);

            var shipmentViewModelFactoryMock = new Mock <ShipmentViewModelFactory>(null, null, null, null, null, null, languageResolverMock.Object);

            _cartItems = new List <CartItemViewModel> {
                new CartItemViewModel {
                    DiscountedPrice = new Money(100, Currency.USD), Quantity = 1
                }
            };
            shipmentViewModelFactoryMock.Setup(x => x.CreateShipmentsViewModel(It.IsAny <ICart>())).Returns(() => new[] { new ShipmentViewModel {
                                                                                                                              CartItems = _cartItems
                                                                                                                          } });

            _referenceConverterMock = new Mock <ReferenceConverter>(null, null);
            _referenceConverterMock.Setup(c => c.GetContentLink(It.IsAny <string>())).Returns(new ContentReference(1));

            var currencyServiceMock = new Mock <ICurrencyService>();

            currencyServiceMock.Setup(x => x.GetCurrentCurrency()).Returns(Currency.USD);

            _totals = new OrderGroupTotals(
                new Money(100, Currency.USD),
                new Money(100, Currency.USD),
                new Money(100, Currency.USD),
                new Money(100, Currency.USD),
                new Money(100, Currency.USD),
                new Dictionary <IOrderForm, OrderFormTotals>());

            _orderDiscountTotal = new Money(5, Currency.USD);
            var orderGroupCalculatorMock = new Mock <IOrderGroupCalculator>();

            orderGroupCalculatorMock.Setup(x => x.GetOrderDiscountTotal(It.IsAny <IOrderGroup>(), It.IsAny <Currency>()))
            .Returns(_orderDiscountTotal);

            orderGroupCalculatorMock.Setup(x => x.GetSubTotal(_cart)).Returns(new Money(_cart.GetAllLineItems().Sum(x => x.PlacedPrice * x.Quantity - ((ILineItemDiscountAmount)x).EntryAmount), _cart.Currency));

            _subject = new CartViewModelFactory(
                contentLoaderMock.Object,
                currencyServiceMock.Object,
                orderGroupCalculatorMock.Object,
                shipmentViewModelFactoryMock.Object,
                _referenceConverterMock.Object);
        }
        protected virtual void MapAdditionalFees(OrderDetailViewModel viewModel, CreateOrderDetailViewModelParam param)
        {
            CartViewModelFactory.MapShipmentsAdditionalFees(GetActiveShipments(param.Order), viewModel.OrderSummary, param.CultureInfo);

            var allLineItems = viewModel.Shipments.SelectMany(x => x.LineItems).ToList();

            viewModel.OrderSummary.AdditionalFeeSummaryList = CartViewModelFactory.GetAdditionalFeesSummary(allLineItems, param.CultureInfo);
        }
 public GraphQLInitialization(
     ICartService cartService,
     CartViewModelFactory cartViewModelFactory,
     ISearchService searchService)
 {
     _cartService          = cartService;
     _cartViewModelFactory = cartViewModelFactory;
     _searchService        = searchService;
 }
示例#14
0
 public CartController(ICurrentCart currentCart, IReadOnlyRepository <Variant> variantRepository, CartViewModelFactory cartViewModelFactory,
                       IUnitOfWork unitOfWork, IPriceService priceService)
 {
     _currentCart          = currentCart;
     _variantRepository    = variantRepository;
     _cartViewModelFactory = cartViewModelFactory;
     _unitOfWork           = unitOfWork;
     _priceService         = priceService;
 }
 public CartController(
     ICartService cartService,
     IOrderRepository orderRepository,
     CartViewModelFactory cartViewModelFactory)
 {
     _cartService          = cartService;
     _orderRepository      = orderRepository;
     _cartViewModelFactory = cartViewModelFactory;
 }
示例#16
0
 public WishListController(
     IContentLoader contentLoader,
     ICartService cartService,
     IOrderRepository orderRepository,
     CartViewModelFactory cartViewModelFactory)
 {
     _contentLoader        = contentLoader;
     _cartService          = cartService;
     _orderRepository      = orderRepository;
     _cartViewModelFactory = cartViewModelFactory;
 }
        protected virtual List <CouponViewModel> MapCoupons(Overture.ServiceModel.Orders.Order order, CultureInfo cultureInfo)
        {
            if (order?.Cart == null)
            {
                return(new List <CouponViewModel>());
            }

            var couponsViewModel = CartViewModelFactory.GetCouponsViewModel(order.Cart, cultureInfo, false);

            return(couponsViewModel != null ? couponsViewModel.ApplicableCoupons : new List <CouponViewModel>());
        }
示例#18
0
        protected virtual async Task <IPaymentMethodViewModel> MapPaymentMethodToViewModel(PaymentMethod paymentMethod, CultureInfo culture)
        {
            var methodDisplayNames = await LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam
            {
                CultureInfo = culture,
                LookupType  = LookupType.Order,
                LookupName  = "PaymentMethodType",
            }).ConfigureAwait(false);

            return(CartViewModelFactory.GetPaymentMethodViewModel(paymentMethod, methodDisplayNames, culture));
        }
示例#19
0
 public CartController(
     ICartService cartService,
     IOrderRepository orderRepository,
     IRecommendationService recommendationService,
     CartViewModelFactory cartViewModelFactory)
 {
     _cartService           = cartService;
     _orderRepository       = orderRepository;
     _recommendationService = recommendationService;
     _cartViewModelFactory  = cartViewModelFactory;
 }
        protected virtual AddressViewModel GetShippingAddressViewModel(CreateOrderDetailViewModelParam param)
        {
            Shipment shipment = GetActiveShipments(param.Order).FirstOrDefault();

            if (shipment == null)
            {
                return(new AddressViewModel());
            }

            // ReSharper disable once PossibleNullReferenceException (The address can be null we will create one)
            return(CartViewModelFactory.GetAddressViewModel(shipment.Address, param.CultureInfo));
        }
 public NavigationController(
     IContentLoader contentLoader,
     ICartService cartService,
     UrlHelper urlHelper,
     LocalizationService localizationService,
     CartViewModelFactory cartViewModelFactory)
 {
     _contentLoader        = contentLoader;
     _cartService          = cartService;
     _urlHelper            = urlHelper;
     _localizationService  = localizationService;
     _cartViewModelFactory = cartViewModelFactory;
 }
示例#22
0
 public SharedCartController(
     IContentLoader contentLoader,
     ICartService cartService,
     IOrderRepository orderRepository,
     CartViewModelFactory cartViewModelFactory,
     ICustomerService customerService,
     ReferenceConverter referenceConverter)
 {
     _contentLoader        = contentLoader;
     _cartService          = cartService;
     _orderRepository      = orderRepository;
     _cartViewModelFactory = cartViewModelFactory;
     _customerService      = customerService;
     _referenceConverter   = referenceConverter;
 }
示例#23
0
        public ChangeCartItemPayload(
            ICartService cartService,
            CartViewModelFactory cartViewModelFactory,
            IOrderRepository orderRepository,
            IRecommendationService recommendationService,
            ServiceAccessor <HttpContextBase> httpContextBase)
        {
            _cartService           = cartService;
            _cartViewModelFactory  = cartViewModelFactory;
            _orderRepository       = orderRepository;
            _recommendationService = recommendationService;
            _httpContextBase       = httpContextBase;

            Name = "ChangeCartItemPayload";

            Field <CartType>("cart");
        }
示例#24
0
        public virtual async Task <CustomerPaymentMethodListViewModel> GetCustomerPaymentMethodListViewModelAsync(GetCustomerPaymentMethodListViewModelParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param), ArgumentNullMessageFormatter.FormatErrorMessage(nameof(param)));
            }

            var tasks = param.ProviderNames.Select(pName => PaymentRepository.GetCustomerPaymentMethodForProviderAsync(new GetCustomerPaymentMethodsForProviderParam
            {
                CustomerId   = param.CustomerId,
                ScopeId      = param.ScopeId,
                ProviderName = pName
            })).ToArray();

            try
            {
                await Task.WhenAll(tasks).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                Log.Warn($"GetCustomerPaymentMethodsRequest failed. {e.ToString()}");
            }

            tasks = tasks.Where(t => !t.IsFaulted).ToArray();
            var paymentMethods = tasks.SelectMany(t => t.Result).ToList();

            var savedCreditCardVm = paymentMethods.Select(s => CartViewModelFactory.MapSavedCreditCard(s, param.CultureInfo)).ToList();

            List <Task> taskList = new List <Task>();

            foreach (var vm in savedCreditCardVm)
            {
                taskList.Add(IsSavedCardUsedInRecurringOrders(vm, param.CultureInfo, param.CustomerId, param.ScopeId));
            }

            await Task.WhenAll(taskList).ConfigureAwait(false);

            return(new CustomerPaymentMethodListViewModel
            {
                SavedCreditCards = savedCreditCardVm
                                   //AddWalletUrl
            });
        }
示例#25
0
 public WishListController(
     IContentLoader contentLoader,
     ICartService cartService,
     IOrderRepository orderRepository,
     CartViewModelFactory cartViewModelFactory,
     IQuickOrderService quickOrderService,
     ReferenceConverter referenceConverter,
     ICustomerService customerService,
     ICartServiceB2B cartServiceB2B)
 {
     _contentLoader        = contentLoader;
     _cartService          = cartService;
     _orderRepository      = orderRepository;
     _cartViewModelFactory = cartViewModelFactory;
     _quickOrderService    = quickOrderService;
     _referenceConverter   = referenceConverter;
     _customerService      = customerService;
     _cartServiceB2B       = cartServiceB2B;
 }
示例#26
0
 public CommerceHeaderViewModelFactory(LocalizationService localizationService,
                                       IAddressBookService addressBookService,
                                       ICustomerService customerService,
                                       CartViewModelFactory cartViewModelFactory,
                                       IUrlResolver urlResolver,
                                       IMarketService marketService,
                                       ICurrentMarket currentMarket,
                                       IBookmarksService bookmarksService,
                                       ICartService cartService,
                                       IContentCacheKeyCreator contentCacheKeyCreator)
 {
     _localizationService    = localizationService;
     _addressBookService     = addressBookService;
     _customerService        = customerService;
     _cartViewModelFactory   = cartViewModelFactory;
     _urlResolver            = urlResolver;
     _marketService          = marketService;
     _currentMarket          = currentMarket;
     _bookmarksService       = bookmarksService;
     _cartService            = cartService;
     _contentCacheKeyCreator = contentCacheKeyCreator;
 }
示例#27
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);
        }
示例#28
0
        /// <summary>
        /// Get the Shipping methods available for a shipment.
        /// </summary>
        /// <param name="param"></param>
        /// <returns>The ShippingMethodsViewModel</returns>
        public async virtual Task <ShippingMethodsViewModel> GetShippingMethodsAsync(GetShippingMethodsParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param", "param is required");
            }
            if (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException("param.CartName is required", "param");
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException("param.Scope is required", "param");
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException("param.CustomerId is required", "param");
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException("param.CultureInfo is required", "param");
            }

            var shippingMethods = await GetFulfillmentMethods(param).ConfigureAwait(false);

            if (shippingMethods == null)
            {
                return(null);
            }

            var shippingMethodViewModels = shippingMethods
                                           .Select(sm => CartViewModelFactory.GetShippingMethodViewModel(sm, param.CultureInfo)).ToList();

            return(new ShippingMethodsViewModel
            {
                ShippingMethods = shippingMethodViewModels
            });
        }
示例#29
0
        public virtual OrderSummaryPaymentViewModel BuildOrderSummaryPaymentViewModel(Overture.ServiceModel.Orders.Payment payment, CultureInfo cultureInfo)
        {
            var methodDisplayNames = LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam
            {
                CultureInfo = cultureInfo,
                LookupType  = LookupType.Order,
                LookupName  = "PaymentMethodType",
            }).Result;

            var paymentMethodDisplayName = methodDisplayNames.FirstOrDefault(x => x.Key == payment.PaymentMethod.Type.ToString()).Value;

            var paymentVm = new OrderSummaryPaymentViewModel
            {
                FirstName         = payment.BillingAddress == null ? null: payment.BillingAddress.FirstName,
                LastName          = payment.BillingAddress == null? null : payment.BillingAddress.LastName,
                PaymentMethodName = paymentMethodDisplayName,
            };

            paymentVm.BillingAddress = CartViewModelFactory.GetAddressViewModel(payment.BillingAddress, cultureInfo);
            paymentVm.Amount         = LocalizationProvider.FormatPrice((decimal)payment.Amount, cultureInfo);

            return(paymentVm);
        }
示例#30
0
        /// <summary>
        /// Get the Shipping methods available for a shipment.
        /// </summary>
        /// <param name="param"></param>
        /// <returns>The ShippingMethodsViewModel</returns>
        public async virtual Task <ShippingMethodsViewModel> GetShippingMethodsAsync(GetShippingMethodsParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }

            var shippingMethods = await GetFulfillmentMethods(param).ConfigureAwait(false);

            if (shippingMethods == null)
            {
                return(null);
            }

            var shippingMethodViewModels = shippingMethods
                                           .Select(sm => CartViewModelFactory.GetShippingMethodViewModel(sm, param.CultureInfo))
                                           .ToList();

            return(new ShippingMethodsViewModel
            {
                ShippingMethods = shippingMethodViewModels
            });
        }