Simplify Tax Calculation
converted foreach if into where statement
This commit is contained in:
parent
2b2897e128
commit
ea46f598bc
@ -117,13 +117,9 @@ namespace RMWPFUserInterface.ViewModels
|
||||
decimal taxAmount = 0;
|
||||
decimal TaxRate = _configHelper.GetTaxRate()/100;
|
||||
|
||||
foreach (var item in Cart)
|
||||
{
|
||||
if (item.Product.IsTaxable)
|
||||
{
|
||||
taxAmount += (item.Product.RetailPrice * item.QuantityInCart * TaxRate);
|
||||
}
|
||||
}
|
||||
taxAmount = Cart
|
||||
.Where(x => x.Product.IsTaxable)
|
||||
.Sum(x => x.Product.RetailPrice * x.QuantityInCart * TaxRate);
|
||||
|
||||
return taxAmount;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user