-
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.
Moving the footer section to a new view component
- Loading branch information
Showing
10 changed files
with
68 additions
and
12 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
OdeToFoodRider/OdeToFoodRider/ViewComponents/GreeterViewComponent.cs
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,21 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using OdeToFoodRider.Services; | ||
|
||
namespace OdeToFoodRider.ViewComponents | ||
{ | ||
public class GreeterViewComponent : ViewComponent | ||
{ | ||
private readonly IGreeter _greeter; | ||
|
||
public GreeterViewComponent(IGreeter greeter) | ||
{ | ||
_greeter = greeter; | ||
} | ||
|
||
public IViewComponentResult Invoke() | ||
{ | ||
var model = _greeter.GetMessageOfTheDay(); | ||
return View("Default", model); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -12,8 +12,3 @@ | |
} | ||
|
||
<div ><a asp-action="Create">Add Restaurant</a></div> | ||
|
||
@section footer | ||
{ | ||
@Model.CurrentMessage | ||
} |
5 changes: 5 additions & 0 deletions
5
OdeToFoodRider/OdeToFoodRider/Views/Shared/Components/Greeter/Default.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,5 @@ | ||
@model string | ||
|
||
<div> | ||
@Model | ||
</div> |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@using OdeToFoodRider.Models | ||
@using OdeToFoodRider.ViewModels | ||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers | ||
@* VSRD: No completion suggestions for assembly name in Rider, too :( - completion for @addTagHelper is available though *@ | ||
@addTagHelper *, OdeToFoodRider |
25 changes: 25 additions & 0 deletions
25
OdeToFoodVisualStudio/OdeToFoodVisualStudio/ViewComponents/GreeterViewComponent.cs
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,25 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using OdeToFoodVisualStudio.Services; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace OdeToFoodVisualStudio.ViewComponents | ||
{ | ||
public class GreeterViewComponent : ViewComponent | ||
{ | ||
private IGreeter _greeter; | ||
|
||
public GreeterViewComponent(IGreeter greeter) | ||
{ | ||
_greeter = greeter; | ||
} | ||
|
||
public IViewComponentResult Invoke() | ||
{ | ||
var model = _greeter.GetMessageOfTheDay(); | ||
return View("Default", model); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -14,7 +14,3 @@ | |
<div> | ||
<a asp-action="Create">Add Restaurant</a> | ||
</div> | ||
|
||
@section footer { | ||
@Model.CurrentMessage | ||
} |
5 changes: 5 additions & 0 deletions
5
OdeToFoodVisualStudio/OdeToFoodVisualStudio/Views/Shared/Components/Greeter/Default.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,5 @@ | ||
@model string | ||
|
||
<div> | ||
@Model | ||
</div> |
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
1 change: 1 addition & 0 deletions
1
OdeToFoodVisualStudio/OdeToFoodVisualStudio/Views/_ViewImports.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,4 +1,5 @@ | ||
@using OdeToFoodVisualStudio.Models; | ||
@using OdeToFoodVisualStudio.ViewModels; | ||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers | ||
@addTagHelper *, OdeToFoodVisualStudio | ||
@* VSRD: Visual Studio provides no completion for the assembly name above *@ |