-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating a layout view and using it from the index view
- Loading branch information
Showing
4 changed files
with
61 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
|
||
<html> | ||
<head> | ||
<title>@ViewBag.Title</title> | ||
</head> | ||
<body> | ||
<div> | ||
@RenderBody() | ||
</div> | ||
<footer>@RenderSection("footer", required: true)</footer> | ||
</body> | ||
</html> |
50 changes: 25 additions & 25 deletions
50
OdeToFoodVisualStudio/OdeToFoodVisualStudio/Views/Home/Index.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
@* VSRD: Visual Studio doesn't suggest importing the Restaurant model when typing @model Restaurant, so you have to type in the FQN. Let's see what Rider can do here :) *@ | ||
@model OdeToFoodVisualStudio.ViewModels.HomeIndexViewModel | ||
|
||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<title></title> | ||
</head> | ||
<body> | ||
@{ ViewBag.Title = "Home page"; | ||
Layout = "~/Views/Shared/_Layout.cshtml"; | ||
} | ||
|
||
<h1>@Model.CurrentMessage</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> | ||
</td> | ||
</tr> | ||
} | ||
</table> | ||
<a asp-action="Create">Add Restaurant</a> | ||
</body> | ||
</html> | ||
<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> | ||
</td> | ||
</tr> | ||
} | ||
</table> | ||
<a asp-action="Create">Add Restaurant</a> | ||
|
||
@section footer { | ||
@Model.CurrentMessage | ||
} |
14 changes: 14 additions & 0 deletions
14
OdeToFoodVisualStudio/OdeToFoodVisualStudio/Views/Shared/_Layout.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
|
||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>@ViewBag.Title</title> | ||
</head> | ||
<body> | ||
<div> | ||
@RenderBody() | ||
</div> | ||
<footer>@RenderSection("footer", required: true)</footer> | ||
</body> | ||
</html> |