Exemple #1
0
        public ProductViewModel(Product product)
        {
            this.Product = product;

            decimal shippingCost = this.Product.ShippingCost.Costs[ShippingType.NationalStandard];

            this.PriceString             = PriceStringUtilities.CreatePriceString(this.Product.Cost);
            this.ShippingPriceString     = $"+ {PriceStringUtilities.CreatePriceString(shippingCost)} s/h";
            this.ShippingPriceVisibility = shippingCost == 0 ? Visibility.Collapsed : Visibility.Visible;
        }
        /// <summary>
        /// Updates the strings that display the cost summary (e.g. sub-total, tax, etc.) of the shopping cart.
        /// </summary>
        private void UpdateCostsSummaryStrings()
        {
            ShoppingCartCostsSummary costsSummary = this.ShoppingCart.CostsSummary;

            // Update values.
            this.SubtotalString          = PriceStringUtilities.CreatePriceString(costsSummary.ItemsSubtotal);
            this.EstimatedShippingString = PriceStringUtilities.CreatePriceString(costsSummary.Shipping);
            this.ShippingTypeString      = ShippingTypeStringUtilities.GetFriendlyNameOfShippingType(this.ShoppingCart.ShippingType);
            this.EstimatedTaxString      = PriceStringUtilities.CreatePriceString(costsSummary.TotalTax);
            this.TotalCostString         = PriceStringUtilities.CreatePriceString(costsSummary.Total);

            // Raise all the 'PropertyChanged' events.
            this.RaisePropertyChanged(nameof(this.SubtotalString));
            this.RaisePropertyChanged(nameof(this.EstimatedShippingString));
            this.RaisePropertyChanged(nameof(this.ShippingTypeString));
            this.RaisePropertyChanged(nameof(this.EstimatedTaxString));
            this.RaisePropertyChanged(nameof(this.TotalCostString));
        }
        /// <summary>
        /// Create the friendly name of a shipping option (including cost).
        /// </summary>
        public static string CreateShippingOptionTitle(ShippingType type, ShoppingCartCostsSummary costs, ShoppingCartCostsSummary currentTotalCost)
        {
            string shippingName = GetFriendlyNameOfShippingType(type);

            if (costs.Total == currentTotalCost.Total)
            {
                return(shippingName);
            }
            else
            {
                decimal costDifference = costs.Total - currentTotalCost.Total;

                if (costDifference >= 0)
                {
                    return($"{shippingName}: +{PriceStringUtilities.CreatePriceString(costDifference)}");
                }
                else
                {
                    return($"{shippingName}: -{PriceStringUtilities.CreatePriceString(-costDifference)}");
                }
            }
        }
Exemple #4
0
 private static PaymentCurrencyAmount CreateCurrencyAmount(decimal value)
 {
     return(new PaymentCurrencyAmount(
                value: PriceStringUtilities.ToInvariantString(value),
                currency: PriceStringUtilities.Currency));
 }