コード例 #1
0
        public int GetCalculatedPrice(int basePrice, int price, int Type)
        {
            if (Type == (int)PriceType.Decreased)
            {
                var PriceDecreasedByPercentage = ConfigurationManagerHelper.PriceDecreaseBy();

                var PriceRangeMinPercentage = ConfigurationManagerHelper.PriceMinimum();

                var MinimumPrice = basePrice * PriceRangeMinPercentage / 100;

                var PriceDecreasedValue = price - (price * PriceDecreasedByPercentage / 100);

                if (PriceDecreasedValue < MinimumPrice)
                {
                    //Set Minimum value-- Should not fall below 75% of base price
                    return(basePrice);
                }
                return(PriceDecreasedValue);
            }
            else
            {
                var PriceIncreasedByPercentage = ConfigurationManagerHelper.PriceIncreaseBy();

                var PriceRangeMaxPercentage = ConfigurationManagerHelper.PriceMaximum();

                var MaximumPrice = basePrice * PriceRangeMaxPercentage / 100;

                var PriceIncreasedValue = price + (price * PriceIncreasedByPercentage / 100);

                if (PriceIncreasedValue > MaximumPrice)
                {
                    //Set Maximum value-- Should not rise above 125% of base price
                    return(basePrice);
                }
                return(PriceIncreasedValue);
            }
        }