8.2 Building the Shopping Cart; Listing 8-17. The Contents of the Index.cshtml File

chap08
Jason Zhu 2021-09-18 18:34:56 +10:00
parent b64c59264b
commit 8dff8292b3
2 changed files with 43 additions and 1 deletions

View File

@ -152,6 +152,7 @@
<Content Include="Scripts\jquery-1.9.0.min.map" /> <Content Include="Scripts\jquery-1.9.0.min.map" />
<Content Include="Views\Shared\ProductSummary.cshtml" /> <Content Include="Views\Shared\ProductSummary.cshtml" />
<Content Include="Views\Nav\Menu.cshtml" /> <Content Include="Views\Nav\Menu.cshtml" />
<Content Include="Views\Cart\Index.cshtml" />
<None Include="Web.Debug.config"> <None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon> <DependentUpon>Web.config</DependentUpon>
</None> </None>
@ -161,7 +162,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="App_Data\" /> <Folder Include="App_Data\" />
<Folder Include="Views\Cart\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SportsStore.Domain\SportsStore.Domain.csproj"> <ProjectReference Include="..\SportsStore.Domain\SportsStore.Domain.csproj">

View File

@ -0,0 +1,42 @@
@model SportsStore.WebUI.Models.CartIndexViewModel
@{
ViewBag.Title = "Sports Store: Your Cart";
}
<h2>Your cart</h2>
<table class="table">
<thead>
<tr>
<th>Quantity</th>
<th>Item</th>
<th class="text-right">Price</th>
<th class="text-right">Subtotal</th>
</tr>
</thead>
<tbody>
@foreach (var line in Model.Cart.Lines) {
<tr>
<td class="text-center">@line.Quantity</td>
<td class="text-left">@line.Product.Name</td>
<td class="text-right">@line.Product.Price.ToString("c")</td>
<td class="text-right">
@((line.Quantity * line.Product.Price).ToString("c"))
</td>
</tr>
}
</tbody>
<tfoot>
<tr>
<td colspan="3" class="text-right">Total:</td>
<td class="text-right">
@Model.Cart.ComputeTotalValue().ToString("c")
</td>
</tr>
</tfoot>
</table>
<div class="text-center">
<a class="btn btn-primary" href="@Model.ReturnUrl">Continue shopping</a>
</div>