Skip to content

Commit

Permalink
Refactoring the Index view to use a new _Summary partial view
Browse files Browse the repository at this point in the history
  • Loading branch information
gorohoroh committed Jul 12, 2018
1 parent d721c76 commit 7c2db66
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 40 deletions.
25 changes: 6 additions & 19 deletions OdeToFoodRider/OdeToFoodRider/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,13 @@
}

<h1>All Restaurants</h1>
@* VSRD: No table snippet in Rider. *@
<table>
@* VSRD: No foreach live template here, just keyword completion like in Visual Studio *@
@foreach (var restaurant in Model.Restaurants)
{
<tr>
<td>@restaurant.Id</td>
<td>@restaurant.Name</td>
<td>
@* VSRD: Rider's path mapping functionality acts weird with the path below *@
<a href="/home/details/@restaurant.Id">Details</a>
@Html.ActionLink("Go", "Details", new {id = restaurant.Id})
<a asp-action="Details" asp-route-id="@restaurant.Id">More</a>
<a asp-page="/Restaurants/Edit" asp-route-id="@restaurant.Id">Edit</a>
</td>
</tr>
}
</table>

<a asp-action="Create">Add Restaurant</a>
@foreach (var restaurant in Model.Restaurants)
{
@Html.Partial("_Summary", restaurant)
}

<div ><a asp-action="Create">Add Restaurant</a></div>

@section footer
{
Expand Down
14 changes: 14 additions & 0 deletions OdeToFoodRider/OdeToFoodRider/Views/Home/_Summary.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@model Restaurant

<section>
<h3>@Model.Name</h3>
<div>
Cuisine: @Model.Cuisine
</div>
<div>
<a asp-action="Details" asp-route-id="@Model.Id">More</a>
<a asp-page="/Restaurants/Edit" asp-route-id="@Model.Id">Edit</a>
</div>

</section>

33 changes: 12 additions & 21 deletions OdeToFoodVisualStudio/OdeToFoodVisualStudio/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,16 @@
}

<h1>All Restaurants</h1>
@* VSRD: Table generated in VS with a "table" code snippet *@
<table>
@* VSRD: No 'foreach' code snippet in VS, just keyword completion *@
@foreach (var restaurant in Model.Restaurants)
{
<tr>
<td>@restaurant.Id</td>
<td>@restaurant.Name</td>
<td>
<a href="/home/details/@restaurant.Id">Details</a>
@Html.ActionLink("Go", "Details", new { id = restaurant.Id })
<a asp-action="Details" asp-route-id="@restaurant.Id">More</a>
<a asp-page="/Restaurants/Edit" asp-route-id="@restaurant.Id">Edit</a>
</td>
</tr>
}
</table>
<a asp-action="Create">Add Restaurant</a>

@section footer {
@Model.CurrentMessage
}
@foreach (var restaurant in Model.Restaurants)
{
@Html.Partial("_Summary", restaurant)
}

<div>
<a asp-action="Create">Add Restaurant</a>
</div>

@section footer {
@Model.CurrentMessage
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@model Restaurant

<section>
<h3>@Model.Name</h3>
<div>
Cuisine: @Model.Cuisine
</div>
<div>
<a asp-action="Details" asp-route-id="@Model.Id">More</a>
<a asp-page="/Restaurants/Edit" asp-route-id="@Model.Id">Edit</a>
</div>

</section>

0 comments on commit 7c2db66

Please sign in to comment.