コード例 #1
0
        public string TotalPrice(string basePrice, string discountIndicator, string stateTax, string quantity)
        {
            double _basePrice;
            int    _quantity;
            bool   _discountIndicator;
            double _taxableAmount;

            //if state is not selected - request for selection
            if (string.IsNullOrWhiteSpace(stateTax))
            {
                return("<B>Please select state<B>");
            }

            double.TryParse(basePrice, out _basePrice);
            Int32.TryParse(quantity, out _quantity);
            bool.TryParse(discountIndicator, out _discountIndicator);
            _taxableAmount = _quantity * _basePrice;
            if (_discountIndicator)
            {
                _taxableAmount = _taxableAmount - (_taxableAmount * 0.1);
            }

            IPriceCalculator priceCalculator = _processLocator.GetProcessor <IPriceCalculator>(stateTax);

            return("Your Total Price will be : " + "<b> $" + priceCalculator.PriceWithTax(_taxableAmount).ToString() + "<b>");
        }