private decimal ComputeDiscount(decimal oldPrice, DefaultPromotionPolicyConfig policyData)
        {
            decimal discount = 0;

            if (policyData.DiscountMode == DiscountMode.ByAmount)
            {
                discount = policyData.DiscountAmount;
            }
            else
            {
                discount = oldPrice * ((decimal)policyData.DiscountPercent / 100);
            }

            if (discount < 0)
            {
                discount = 0;
            }
            if (discount > oldPrice)
            {
                discount = oldPrice;
            }

            return(discount);
        }
예제 #2
0
        private decimal ComputeDiscount(decimal oldPrice, DefaultPromotionPolicyConfig policyData)
        {
            decimal discount = 0;

            if (policyData.DiscountMode == DiscountMode.ByAmount)
            {
                discount = policyData.DiscountAmount;
            }
            else
            {
                discount = oldPrice * ((decimal)policyData.DiscountPercent / 100);
            }

            if (discount < 0)
            {
                discount = 0;
            }
            if (discount > oldPrice)
            {
                discount = oldPrice;
            }

            return discount;
        }