Exemplo n.º 1
0
        public static QuoteItem ToQuoteItem(this Product product, long quantity)
        {
            var quoteItem = new QuoteItem();

            quoteItem.InjectFrom <NullableAndEnumValueInjecter>(product);

            quoteItem.Id        = null;
            quoteItem.ImageUrl  = product.PrimaryImage != null ? product.PrimaryImage.Url : null;
            quoteItem.ListPrice = product.Price.ListPrice;
            quoteItem.ProductId = product.Id;
            quoteItem.SalePrice = product.Price.SalePrice;
            quoteItem.ProposalPrices.Add(new TierPrice(product.Price.SalePrice, quantity));
            quoteItem.SelectedTierPrice = quoteItem.ProposalPrices.First();

            return(quoteItem);
        }
Exemplo n.º 2
0
        public virtual QuoteItem ToQuoteItem(Product product, long quantity)
        {
            var retVal = new QuoteItem();

            retVal.InjectFrom <NullableAndEnumValueInjecter>(product);

            retVal.Id        = null;
            retVal.ImageUrl  = product.PrimaryImage != null ? product.PrimaryImage.Url : null;
            retVal.ListPrice = product.Price.ListPrice;
            retVal.ProductId = product.Id;
            retVal.SalePrice = product.Price.SalePrice;
            retVal.ProposalPrices.Add(new TierPrice(product.Price.SalePrice, quantity));
            retVal.SelectedTierPrice = retVal.ProposalPrices.First();

            return(retVal);
        }
Exemplo n.º 3
0
        public static QuoteItem ToWebModel(this QuoteModule.Client.Model.QuoteItem serviceModel, Currency currency)
        {
            var webModel = new QuoteItem();

            webModel.InjectFrom <NullableAndEnumValueInjecter>(serviceModel);

            webModel.Currency  = currency;
            webModel.ListPrice = new Money(serviceModel.ListPrice ?? 0, currency);
            webModel.SalePrice = new Money(serviceModel.SalePrice ?? 0, currency);

            if (serviceModel.ProposalPrices != null)
            {
                webModel.ProposalPrices = serviceModel.ProposalPrices.Select(pp => pp.ToWebModel(currency)).ToList();
            }

            if (serviceModel.SelectedTierPrice != null)
            {
                webModel.SelectedTierPrice = serviceModel.SelectedTierPrice.ToWebModel(currency);
            }

            return(webModel);
        }
Exemplo n.º 4
0
        public virtual QuoteItem ToQuoteItem(quoteDto.QuoteItem quoteItemDto, Currency currency)
        {
            var result = new QuoteItem();

            result.InjectFrom <NullableAndEnumValueInjecter>(quoteItemDto);

            result.Currency  = currency;
            result.ListPrice = new Money(quoteItemDto.ListPrice ?? 0, currency);
            result.SalePrice = new Money(quoteItemDto.SalePrice ?? 0, currency);

            if (quoteItemDto.ProposalPrices != null)
            {
                result.ProposalPrices = quoteItemDto.ProposalPrices.Select(pp => ToTierPrice(pp, currency)).ToList();
            }

            if (quoteItemDto.SelectedTierPrice != null)
            {
                result.SelectedTierPrice = ToTierPrice(quoteItemDto.SelectedTierPrice, currency);
            }

            return(result);
        }
Exemplo n.º 5
0
        public static QuoteItem ToShopifyModel(this Storefront.Model.Quote.QuoteItem storefrontModel)
        {
            var shopifyModel = new QuoteItem();

            shopifyModel.InjectFrom <NullableAndEnumValueInjecter>(storefrontModel);

            shopifyModel.Currency  = storefrontModel.Currency.ToShopifyModel();
            shopifyModel.ListPrice = storefrontModel.ListPrice.Amount * 100;

            shopifyModel.ProposalPrices = new List <TierPrice>();
            foreach (var proposalPrice in storefrontModel.ProposalPrices)
            {
                shopifyModel.ProposalPrices.Add(proposalPrice.ToShopifyModel());
            }

            shopifyModel.SalePrice = storefrontModel.SalePrice.Amount * 100;

            if (storefrontModel.SelectedTierPrice != null)
            {
                shopifyModel.SelectedTierPrice = storefrontModel.SelectedTierPrice.ToShopifyModel();
            }

            return(shopifyModel);
        }
        public virtual QuoteItem ToLiquidQuoteItem(Storefront.Model.Quote.QuoteItem quoteItem)
        {
            var result = new QuoteItem();

            result.InjectFrom <NullableAndEnumValueInjecter>(quoteItem);

            result.Currency  = ToLiquidCurrency(quoteItem.Currency);
            result.ListPrice = quoteItem.ListPrice.Amount * 100;

            result.ProposalPrices = new List <TierPrice>();
            foreach (var proposalPrice in quoteItem.ProposalPrices)
            {
                result.ProposalPrices.Add(ToLiquidTierPrice(proposalPrice));
            }

            result.SalePrice = quoteItem.SalePrice.Amount * 100;

            if (quoteItem.SelectedTierPrice != null)
            {
                result.SelectedTierPrice = ToLiquidTierPrice(quoteItem.SelectedTierPrice);
            }

            return(result);
        }