9.3.2 Adding the Checkout Process; Listing 9-12 Reducing Duplication in the Checkout.cshtml File

chap09
Jason Zhu 2021-09-22 14:19:19 +10:00
parent 4090de140a
commit 9491c62113
1 changed files with 10 additions and 29 deletions

View File

@ -17,35 +17,16 @@
</div>
<h3>Address</h3>
foreach (var property in ViewData.ModelMetadata.Properties)
{
if (property.PropertyName != "Name" && property.PropertyName != "GiftWrap")
{
<div class="form-group">
<label>Line 1:</label>
@Html.TextBoxFor(x => x.Line1, new { @class = "form-control" })
</div>
<div class="form-group">
<label>Line 2:</label>
@Html.TextBoxFor(x => x.Line2, new { @class = "form-control" })
</div>
<div class="form-group">
<label>Line 3:</label>
@Html.TextBoxFor(x => x.Line3, new { @class = "form-control" })
</div>
<div class="form-group">
<label>City:</label>
@Html.TextBoxFor(x => x.City, new { @class = "form-control" })
</div>
<div class="form-group">
<label>State:</label>
@Html.TextBoxFor(x => x.State, new { @class = "form-control" })
</div>
<div class="form-group">
<label>Zip:</label>
@Html.TextBoxFor(x => x.Zip, new { @class = "form-control" })
</div>
<div class="form-group">
<label>Country:</label>
@Html.TextBoxFor(x => x.Country, new { @class = "form-control" })
<label>@(property.DisplayName ?? property.PropertyName)</label>
@Html.TextBox(property.PropertyName, null, new { @class = "form-control" })
</div>
}
}
<h3>Options</h3>
<div class="checkbox">