Skip to content

Commit

Permalink
Using Razor Pages
Browse files Browse the repository at this point in the history
  • Loading branch information
gorohoroh committed Jul 10, 2018
1 parent 043ba15 commit e7d3fbb
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 2 deletions.
2 changes: 1 addition & 1 deletion OdeToFoodRider/OdeToFoodRider.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OdeToFoodRider", "OdeToFoodRider\OdeToFoodRider.csproj", "{570AED0D-E198-4308-8F55-EB8E8473A26B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OdeToFoodRider", "OdeToFoodRider\OdeToFoodRider.csproj", "{570AED0D-E198-4308-8F55-EB8E8473A26B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
5 changes: 5 additions & 0 deletions OdeToFoodRider/OdeToFoodRider/Pages/Greeting.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@page "{name}"

@model GreetingModel

<div>@Model.CurrentGreeting</div>
22 changes: 22 additions & 0 deletions OdeToFoodRider/OdeToFoodRider/Pages/Greeting.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using OdeToFoodRider.Services;

namespace OdeToFoodRider.Pages
{
public class GreetingModel : PageModel
{
private readonly IGreeter _greeter;

public string CurrentGreeting { get; set; }

public GreetingModel(IGreeter greeter)
{
_greeter = greeter;
}

public void OnGet(string name)
{
CurrentGreeting = $"{name}: {_greeter.GetMessageOfTheDay()}";
}
}
}
13 changes: 13 additions & 0 deletions OdeToFoodRider/OdeToFoodRider/Pages/_Layout.cshtml
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: false)</footer>
</body>
</html>
5 changes: 5 additions & 0 deletions OdeToFoodRider/OdeToFoodRider/Pages/_ViewImports.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@using OdeToFoodRider.Models
@using OdeToFoodRider.ViewModels
@using OdeToFoodRider.Pages;
@using OdeToFoodRider.Services;
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
3 changes: 3 additions & 0 deletions OdeToFoodRider/OdeToFoodRider/Pages/_ViewStart.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@{
Layout = "_Layout.cshtml";
}
2 changes: 1 addition & 1 deletion OdeToFoodVisualStudio/OdeToFoodVisualStudio.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2035
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OdeToFoodVisualStudio", "OdeToFoodVisualStudio\OdeToFoodVisualStudio.csproj", "{4F4A0317-B875-4C01-BF86-03CD0C50ADE5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OdeToFoodVisualStudio", "OdeToFoodVisualStudio\OdeToFoodVisualStudio.csproj", "{4F4A0317-B875-4C01-BF86-03CD0C50ADE5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@page "{name}"

@model GreetingModel

<div>@Model.CurrentGreeting</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using OdeToFoodVisualStudio.Services;

namespace OdeToFoodVisualStudio.Pages
{
public class GreetingModel : PageModel
{
private IGreeter _greeter;

public string CurrentGreeting { get; set; }

public GreetingModel(IGreeter greeter)
{
_greeter = greeter;
}

public void OnGet(string name)
{
CurrentGreeting = $"{name}: {_greeter.GetMessageOfTheDay()}";
}
}
}
14 changes: 14 additions & 0 deletions OdeToFoodVisualStudio/OdeToFoodVisualStudio/Pages/_Layout.cshtml
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: false)</footer>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@using OdeToFoodVisualStudio.Models;
@using OdeToFoodVisualStudio.ViewModels;
@using OdeToFoodVisualStudio.Pages;
@using OdeToFoodVisualStudio.Services;
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@{
Layout = "_Layout.cshtml";
}

0 comments on commit e7d3fbb

Please sign in to comment.