From 9491c62113fdf0afff6f983944af59055e437146 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Wed, 22 Sep 2021 14:19:19 +1000 Subject: [PATCH] 9.3.2 Adding the Checkout Process; Listing 9-12 Reducing Duplication in the Checkout.cshtml File --- .../Views/Cart/Checkout.cshtml | 39 +++++-------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/SportsStore/SportsStore.WebUI/Views/Cart/Checkout.cshtml b/SportsStore/SportsStore.WebUI/Views/Cart/Checkout.cshtml index c851840..fa41dba 100644 --- a/SportsStore/SportsStore.WebUI/Views/Cart/Checkout.cshtml +++ b/SportsStore/SportsStore.WebUI/Views/Cart/Checkout.cshtml @@ -17,35 +17,16 @@

Address

- -
- - @Html.TextBoxFor(x => x.Line1, new { @class = "form-control" }) -
-
- - @Html.TextBoxFor(x => x.Line2, new { @class = "form-control" }) -
-
- - @Html.TextBoxFor(x => x.Line3, new { @class = "form-control" }) -
-
- - @Html.TextBoxFor(x => x.City, new { @class = "form-control" }) -
-
- - @Html.TextBoxFor(x => x.State, new { @class = "form-control" }) -
-
- - @Html.TextBoxFor(x => x.Zip, new { @class = "form-control" }) -
-
- - @Html.TextBoxFor(x => x.Country, new { @class = "form-control" }) -
+ foreach (var property in ViewData.ModelMetadata.Properties) + { + if (property.PropertyName != "Name" && property.PropertyName != "GiftWrap") + { +
+ + @Html.TextBox(property.PropertyName, null, new { @class = "form-control" }) +
+ } + }

Options