Skip to content

Instantly share code, notes, and snippets.

@kasunkv
Created May 12, 2019 14:14
Show Gist options
  • Save kasunkv/e1faa6612430a4c78beeee730576a57f to your computer and use it in GitHub Desktop.
Save kasunkv/e1faa6612430a4c78beeee730576a57f to your computer and use it in GitHub Desktop.
Implementation of IDiscountProcessor.cs
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