//--------------------------------------------------------
        public decimal ComputeBuyQuantityDiscount( PricingRule pr, ShoppingCartItem scItem)
        {
            int discountCount = 0;
            decimal discount = 0;
            int discountMuliplier = 1;
            if ((pr != null) && scItem != null && (scItem.Quantity > 0) &&
                (   (pr.DiscountRuleEnumType == DiscountRuleEnum.BuyOneGetFree) ||
                    (pr.DiscountRuleEnumType == DiscountRuleEnum.BuyQuantityGetFree) ||
                    (pr.DiscountRuleEnumType == DiscountRuleEnum.BuyOneGetDiscount) ||
                    (pr.DiscountRuleEnumType == DiscountRuleEnum.BuyQuantityGetDiscount)
                )
               )
            {
                int tempMultiplier = (int)scItem.Quantity / (int)(pr.BuyQuantity + pr.DiscountQuantity);
                discountMuliplier = (tempMultiplier == 0) ? 1 : tempMultiplier;

                int tempCount = (int)(scItem.Quantity - pr.BuyQuantity);
                if(pr.DiscountQuantity > 0)
                    discountCount = tempCount > (int)pr.DiscountQuantity ? (int)pr.DiscountQuantity : tempCount;

                if (discountCount > 0)
                    discount = (decimal)(scItem.Product.Price * (pr.DiscountPercent) * discountCount * discountMuliplier)/100;
            }
            else if ((pr != null) && (pr.DiscountRuleEnumType == DiscountRuleEnum.DiscountPercent))
                discount = discount + (decimal)(scItem.Product.Price * pr.DiscountPercent/100);
            //else if ((pr != null) && (pr.DiscountRuleEnumType == DiscountRuleEnum.DiscountedAmount))
                //discount = discount + (decimal)pr.DiscountedAmount;

            return discount;
        }
        public ShoppingCartVM()
        {
            Invoice = new Invoice() { };
            PricingRule = new PricingRule();
            ShoppingCartItem = new ShoppingCartItem();

            ProductList = new List<Product>() { };
            ShoppingCartPricingRuleList = new List<PricingRule>() { };
            CartItemList = new List<ShoppingCartItem>() { };
        }
 //--------------------------------------------------------
 public ShoppingCartItem CopyItem(ShoppingCartItem source, ShoppingCartItem destination)
 {
     destination.ShoppingCartItemId = source.ShoppingCartItemId;
     destination.Date = source.Date;
     destination.ProductId = source.ProductId;
     destination.PricingRuleId = source.PricingRuleId;
     destination.Discount = 0;
     destination.Quantity = 1;
     destination.Product = source.Product;
     return destination;
 }
 //--------------------------------------------------------
 public void ProcessBuyQuantityForRemainder(ref List<ShoppingCartItem> gscList, ShoppingCartItem scItem)
 {
     if (gscList != null && scItem != null)
     {
         int i = (int)scItem.Quantity;
         while (i > 0)
         {
             ShoppingCartItem item = new ShoppingCartItem();
             item = CopyItem(scItem, item);
             item.Total = item.Product.Price;
             gscList.Add(item);
             i--;
         }
     }
 }