Activity: Revising the Code to Show Discount in the Total

Scenario

You want to revise the code so that it discounts the total sum by 10% if the total amount is larger than 1,000 and show this discount in the total.

Aim

Revise the code to show discount in the total.

Steps for completion

  1. Change the Order class, as follows:

Go to https://goo.gl/Q58VD2 to access the code.
public class Order
{
public int OrderId { get; set; }
public List<Product> Products { get; set; }
public decimal Total { get; set; }
public decimal Discount => Total > 1000M ? Total * 0.1M : Total;
}
  1. Change the view, as follows:

Go to https://goo.gl/ScepWa to access the code.
@model Lesson4.Models.Order
<table border="1">
<tr>
<th>Product Name</th>
<th>Price</th>
</tr>
@foreach (var Product in Model.Products)
{
<tr>
<td>@Product.Name</td>
<td>@Product.Price</td>
</tr>
}
...
...
</table>