/// <summary>
        /// Constructor for a new order
        /// </summary>
        /// <param name="shippingMethodName">The selected shipping method</param>
        /// <param name="shoppingCartList">The customers current shopping cart</param>
        /// <param name="globalShippingPrice">The global shipping price for tghe selected shipping method</param>
        /// <param name="globalTaxAmount">The global tax amount</param>
        public PurchaseOrderDetails(string shippingMethodName, List <ShoppingCartProduct> shoppingCartList, decimal globalShippingPrice, string globalTaxAmount) : this()
        {
            PayPalOrderDetails.ShippingMethodType = shippingMethodName;
            PayPalOrderDetails.ShippingAmount     = globalShippingPrice;
            GlobalShippingPrice = globalShippingPrice;
            GlobalTaxAmount     = Decimal.Parse(globalTaxAmount);

            if (shoppingCartList != null && shoppingCartList.Count > 0)
            {
                foreach (var ShopCartProd in shoppingCartList)
                {
                    PurchasedProduct PurchasedProd = new PurchasedProduct(shippingMethodName, ShopCartProd);

                    PayPalOrderDetails.BaseAmount     += PurchasedProd.PurchasePrice * PurchasedProd.Quantity;
                    PayPalOrderDetails.ShippingAmount += PurchasedProd.ShippingPrice;

                    PurchasedProductList.Add(PurchasedProd);
                }
            }

            PayPalOrderDetails.TaxAmount = PayPalOrderDetails.BaseAmount * GlobalTaxAmount;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor for a new order
        /// </summary>
        /// <param name="shippingMethodName">The selected shipping method</param>
        /// <param name="shoppingCartList">The customers current shopping cart</param>
        /// <param name="globalShippingPrice">The global shipping price for tghe selected shipping method</param>
        /// <param name="globalTaxAmount">The global tax amount</param>
        public PurchaseOrderDetails(string shippingMethodName, List<ShoppingCartProduct> shoppingCartList, decimal globalShippingPrice, string globalTaxAmount)
            : this()
        {
            PayPalOrderDetails.ShippingMethodType = shippingMethodName;
            PayPalOrderDetails.ShippingAmount = globalShippingPrice;
            GlobalShippingPrice = globalShippingPrice;
            GlobalTaxAmount = Decimal.Parse(globalTaxAmount);

            if (shoppingCartList != null && shoppingCartList.Count > 0)
            {
                foreach (var ShopCartProd in shoppingCartList)
                {
                    PurchasedProduct PurchasedProd = new PurchasedProduct(shippingMethodName, ShopCartProd);

                    PayPalOrderDetails.BaseAmount += PurchasedProd.PurchasePrice * PurchasedProd.Quantity;
                    PayPalOrderDetails.ShippingAmount += PurchasedProd.ShippingPrice;

                    PurchasedProductList.Add(PurchasedProd);
                }
            }

            PayPalOrderDetails.TaxAmount = PayPalOrderDetails.BaseAmount * GlobalTaxAmount;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Update the real product's stock with the quantity selected from the user's purchased product
        /// </summary>
        /// <param name="purchProduct">The product the user purchased</param>
        public void UpdateStock(PurchasedProduct purchProduct)
        {
            bool FoundUniqueCheckoutPropKey = false;

            if (purchProduct.SelectedCheckoutProperties != null && purchProduct.SelectedCheckoutProperties.Count > 0)
            {
                if(CheckoutPropertySettingsList != null && CheckoutPropertySettingsList.Count > 0)
                {
                    foreach (var CheckoutPropSetting in CheckoutPropertySettingsList)
                    {
                        if(purchProduct.GetUniqueCheckoutPropertyKey().Equals(CheckoutPropSetting.GetUniqueCheckoutPropertyKey()))
                        {
                            CheckoutPropSetting.PurchaseSettings.StockLevel -= purchProduct.Quantity;
                            FoundUniqueCheckoutPropKey = true;
                            break;
                        }
                    }
                }
            }

            if (!FoundUniqueCheckoutPropKey)
            {
                PurchaseSettings.StockLevel -= purchProduct.Quantity;
            }
        }