mirror of
https://github.com/rudollee/LearningMVC.git
synced 2026-08-11 16:32:55 +00:00
Chapter 5 Added
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
@using Razor.Models
|
||||
@model Razor.Models.Product[]
|
||||
@{
|
||||
ViewBag.Title = "DemoArray";
|
||||
}
|
||||
|
||||
@if (Model.Length > 0)
|
||||
{
|
||||
<table>
|
||||
<thead><tr><th>Product</th><th>Price</th></tr></thead>
|
||||
<tbody>
|
||||
@foreach (Product p in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@p.Name</td>
|
||||
<td>@p.Price</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
@model Razor.Models.Product
|
||||
|
||||
@{
|
||||
ViewBag.Title = "DemoExpression";
|
||||
}
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Property</th><th>Value</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td>Name</td><td>@Model.Name</td></tr>
|
||||
<tr><td>Price</td><td>@Model.Price</td></tr>
|
||||
<tr>
|
||||
<td>Stock Level</td>
|
||||
<td>
|
||||
@switch ((int)ViewBag.ProductCount)
|
||||
{
|
||||
case 0:
|
||||
@: Out of Stock
|
||||
break;
|
||||
case 1:
|
||||
<b>Low Stock (@ViewBag.ProductCount)</b>
|
||||
break;
|
||||
case 2:
|
||||
@ViewBag.ProductCount
|
||||
break;
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div data-discount="@ViewBag.ApplyDiscount" data-express="@ViewBag.ExpressShip" data-supplier="@ViewBag.Supplier">
|
||||
The containing element has data attributes
|
||||
</div>
|
||||
|
||||
Discount: <input type="checkbox" checked="@ViewBag.ApplyDiscount" />
|
||||
Express: <input type="checkbox" checked="@ViewBag.ExpressShip" />
|
||||
Supplier: <input type="checkbox" checked="@ViewBag.Supplier" />
|
||||
@@ -0,0 +1,19 @@
|
||||
@model Razor.Models.Product
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Product Name";
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>Index</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
Product Name: @Model.Name
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,9 @@
|
||||
@model Razor.Models.Product
|
||||
|
||||
@{
|
||||
ViewBag.Title = "NameAndPrice";
|
||||
Layout = "~/Views/_BasicLayout.cshtml";
|
||||
}
|
||||
|
||||
<h2>NameAndPrice</h2>
|
||||
The product name is @Model.Name and it costs $@Model.Price
|
||||
Reference in New Issue
Block a user