Beispiel #1
0
        public decimal ApplyDiscount(decimal price, AccountStatus accountStatus, int timeofHavingInYears)
        {
            decimal priceAfterDiscount           = 0;
            decimal discountForYearsInPercentage = (timeofHavingInYears > Constants.MAXIMUM_DISCOUNT_VALUE) ? (decimal)Constants.MAXIMUM_DISCOUNT_VALUE / 100 : (decimal)timeofHavingInYears / 100;

            switch (accountStatus)
            {
            case AccountStatus.NotRegistered:
                priceAfterDiscount = price;
                break;

            case AccountStatus.SimpleCustomer:
                priceAfterDiscount = price.ApplyDiscountForAccountStatus(Constants.DISCOUNT_SIMPLE_CUSTOMER);
                break;

            case AccountStatus.MostValuableCustomer:
                priceAfterDiscount = price.ApplyDiscountForAccountStatus(Constants.DISCOUNT_MOST_VALUABLE_CUSTOMER);
                break;

            case AccountStatus.ValuableCustomer:
                priceAfterDiscount = price.ApplyDiscountForAccountStatus(Constants.DISCOUNT_VALUABLE_CUSTOMER);
                break;

            default:
                throw new NotImplementedException();
            }
            priceAfterDiscount.ApplyDiscountForTimeOfHavingAccount(timeofHavingInYears);
            return(priceAfterDiscount);
        }
        public static decimal ApplyDiscount(decimal price, AccountStatus accountStatus, int timeOfHavingAccountInYears)
        {
            decimal priceAfterDiscount = 0;

            switch (accountStatus)
            {
            case AccountStatus.NotRegistered:
                priceAfterDiscount = price;
                break;

            case AccountStatus.SimpleCustomer:
                priceAfterDiscount = price.ApplyDiscountForAccountStatus(Constants2.DISCOUNT_FOR_SIMPLE_CUSTOMERS);
                break;

            case AccountStatus.ValuableCustomer:
                priceAfterDiscount = price.ApplyDiscountForAccountStatus(Constants2.DISCOUNT_FOR_VALUABLE_CUSTOMERS);
                break;

            case AccountStatus.MostValuableCustomer:
                priceAfterDiscount = price.ApplyDiscountForAccountStatus(Constants2.DISCOUNT_FOR_MOST_VALUABLE_CUSTOMERS);
                break;

            default:
                throw new NotImplementedException();
            }
            priceAfterDiscount = priceAfterDiscount.ApplyDiscountForTimeOfHavingAccount(timeOfHavingAccountInYears);
            return(priceAfterDiscount);
        }
Beispiel #3
0
        public decimal ApplyDiscount(decimal price, AccountStatus accountStatus, int timeOfHavingAccountInYears)
        {
            decimal priceAfterDiscount;

            switch (accountStatus)
            {
            case AccountStatus.NotRegistered:
                priceAfterDiscount = price;
                break;

            case AccountStatus.SimpleCustomer:
                priceAfterDiscount = price.ApplyDiscountForAccountStatus(constants.DiscountForSimpleCustomers);
                break;

            case AccountStatus.ValuableCustomer:
                priceAfterDiscount = price.ApplyDiscountForAccountStatus(constants.DiscountForValuableCustomers);
                break;

            case AccountStatus.MostValuableCustomer:
                priceAfterDiscount = price.ApplyDiscountForAccountStatus(constants.DiscountForMostValuableCustomers);
                break;

            default:
                throw new NotImplementedException();
            }
            if (accountStatus != AccountStatus.NotRegistered)
            {
                priceAfterDiscount = priceAfterDiscount.ApplyDiscountForTimeOfHavingAccount(timeOfHavingAccountInYears);
            }
            return(priceAfterDiscount);
        }