Example #1
0
 public CalculateCartFlow(ICalculateSubTotal calculateSubTotal, ICalculateTax calculateTax, ICalculateDiscount calculateDiscount, ICalculateTotal calculateTotal)
 {
     this.calculateSubTotal = calculateSubTotal;
     this.calculateTax      = calculateTax;
     this.calculateDiscount = calculateDiscount;
     this.calculateTotal    = calculateTotal;
 }
Example #2
0
 public CalculateCartFlow(CalculateSubTotal calculateSubTotal,
                          CalculateTax calculateTax, CalculateDiscount calculateDiscount,
                          CalculateGrandTotal calculateGrandTotal)
 {
     this.calculateSubTotal   = calculateSubTotal;
     this.calculateTax        = calculateTax;
     this.calculateDiscount   = calculateDiscount;
     this.calculateGrandTotal = calculateGrandTotal;
 }
Example #3
0
        public TaxTests()
        {
            var services = new ServiceCollection();

            services.AddTransient <ITaxTypeRepository, TaxTypeRepository>();
            services.AddTransient <ITaxCalculationRepository, TaxCalculationRepository>();

            services.AddSingleton <ICalculateTax, CalculateTax>();
            services.AddSingleton <IDataLayer, DataLayer>();

            var serviceProvider = services.BuildServiceProvider();

            //_dataLayer = serviceProvider.GetService<IDataLayer>();
            _calculateTax = serviceProvider.GetService <ICalculateTax>();
        }
Example #4
0
        public decimal Process(ICalculateTax taxCalculator)
        {
            // hardcoding some quantities and prices for this example
            long    itemNumber = 3;
            decimal itemPrice  = 7.99m; // pretending that the price is the same in all currencies :)
            bool    isFood     = false;

            // Lots of other order pre-processing going on here...
            // ...

            // Calculate the tax
            decimal tax = taxCalculator.TaxAmount(itemNumber, itemPrice, isFood);

            // Lots of order payment processing and receipt generation going on here...
            // ...

            Console.WriteLine("Total tax amount on 23.97 is: {0}", tax);

            return((itemNumber * itemPrice) + tax);
        }
Example #5
0
 /// <summary>
 /// Simulates a call to process an order
 /// </summary>
 /// <param name="taxCalculator">This parameter would be determined by logic/config
 /// elsewhere that contained business rules that would determine which tax formula to use</param>
 private static void ProcessOrder(ICalculateTax taxCalculator)
 {
     IOrder  order = new Order(); // NOTE: We would normally use a factory or something to create the Order class
     decimal total = order.Process(taxCalculator);
 }
Example #6
0
 public SalesOrder(ICalculateTax taxCalculator)
 {
     this.taxCalculator = taxCalculator;
 }
Example #7
0
 public TaxServicesController(ICalculateTax calculateTax, IDataLayer dataLayer)
 {
     _dataLayer    = dataLayer;
     _calculateTax = calculateTax;
 }