Skip to content

Commit

Permalink
Creating and rendering a Razor view
Browse files Browse the repository at this point in the history
  • Loading branch information
gorohoroh committed Jul 3, 2018
1 parent f657b1f commit 21a5fc3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public IActionResult Index()
{
var model = new Restaurant() {Id = 1, Name = "Scott's Pizza Place"};

return new ObjectResult(model);
return View(model);
}
}
}
14 changes: 14 additions & 0 deletions OdeToFoodRider/OdeToFoodRider/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@using OdeToFoodRider.Models
@model Restaurant

<!DOCTYPE html>

<html>
<head>
<title>My title</title>
</head>
<body>
<h1>@Model.Name</h1>
<div>The ID value is @Model.Id</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ public IActionResult Index()
{
var model = new Restaurant { Id = 1, Name = "Scott's Pizza Place" };

return new ObjectResult(model);

// VSRD: Visual Studio doesn't have a quick action to change return type if you try to return something that doesn't match it
// VSRD: Visual Studio's take on Extend/Shrink Selection (Shift+Alt+Plus/Minus) can't extend to a string literal except quotes,
// making it non-trivial to paste text into string literals - it can only extend to the whole string literal
//return Content("Hello from Visual Studio's Home controller");

return View(model);

}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@* 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.Models.Restaurant

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
@* VSRD: Visual Studio doesn't seem to provide Extend/Shrink selection in cshtml editor *@
<h1>@Model.Name</h1>
<div>The ID value is @Model.Id</div>
</body>
</html>

0 comments on commit 21a5fc3

Please sign in to comment.