Пример #1
0
        public decimal ApplyDiscount(decimal price, AccountStatus accountStatus, int timeOfHavingAccountInYears)
        {
            decimal priceAfterDiscount = 0;

            #region old code
            //switch (accountStatus)
            //{
            //	case AccountStatus.NotRegistered:
            //	priceAfterDiscount = price;
            //	break;
            //	case AccountStatus.SimpleCustomer:
            //	priceAfterDiscount = price.ApplyDiscountForAccountStatus(Constants.DISCOUNT_FOR_SIMPLE_CUSTOMERS);
            //	break;
            //	case AccountStatus.ValuableCustomer:
            //	priceAfterDiscount = price.ApplyDiscountForAccountStatus(Constants.DISCOUNT_FOR_VALUABLE_CUSTOMERS);
            //	break;
            //	case AccountStatus.MostValuableCustomer:
            //	priceAfterDiscount = price.ApplyDiscountForAccountStatus(Constants.DISCOUNT_FOR_MOST_VALUABLE_CUSTOMERS);
            //	break;
            //	default:
            //	throw new NotImplementedException();
            //}
            //priceAfterDiscount = priceAfterDiscount.ApplyDiscountForTimeOfHavingAccount(timeOfHavingAccountInYears);
            #endregion

            priceAfterDiscount = _factory.GetAccountDiscountCalculator(accountStatus).ApplyDiscount(price);
            priceAfterDiscount = _loyaltyDiscountCalculator.ApplyDiscount(priceAfterDiscount, timeOfHavingAccountInYears);
            return(priceAfterDiscount);
        }
Пример #2
0
        public decimal ApplyDiscount(decimal price, AccountStatus accountStatus, int timeofHavingAccountInYears)
        {
            decimal priceAfterDiscount = 0;

            priceAfterDiscount = _factory.GetAccountDiscountCalculator(accountStatus).ApplyDiscount(price);
            return(_loyaltyDiscountCalculator.ApplyDiscount(price, timeofHavingAccountInYears));
        }
Пример #3
0
        public decimal ApplyDiscount(decimal price, AccountStatus accountStatus, int timeOfHavingAccountInYears)
        {
            var priceAfterDiscount = factory.GetAccountDiscountCalculator(accountStatus).ApplyDiscount(price);

            priceAfterDiscount =
                loyaltyDiscountCalculator.ApplyDiscount(priceAfterDiscount, accountStatus, timeOfHavingAccountInYears);
            return(priceAfterDiscount);
        }