Created
May 12, 2019 14:14
-
-
Save kasunkv/e1faa6612430a4c78beeee730576a57f to your computer and use it in GitHub Desktop.
Implementation of IDiscountProcessor.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OrderDiscountProcessor : IDiscountProcessor | |
{ | |
private readonly Discount _discount; | |
public OrderDiscountProcessor(Discount discount) | |
{ | |
_discount = discount; | |
} | |
public double ProcessDiscount(OrderViewModel order) | |
{ | |
double discount = 0.0; | |
double totalBill = order.Quantity * order.Price; | |
if (order.Quantity >= _discount.MinimumItemCount && totalBill >= _discount.MinimumBillAmount) | |
{ | |
discount = (totalBill * _discount.Percentage) / 100.0; | |
} | |
return discount; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment