Skip to content

Commit

Permalink
Tutorial Edits
Browse files Browse the repository at this point in the history
Register the PizzaService class with the dependency injection container
  • Loading branch information
kathleenwest committed Oct 14, 2023
1 parent 0e29c3d commit cdb82cd
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 8 deletions.
7 changes: 6 additions & 1 deletion ContosoPizza.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33627.172
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContosoPizza", "ContosoPizza\ContosoPizza.csproj", "{0815BE9C-C896-4269-AF9A-68F4D16FCDC9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContosoPizza", "ContosoPizza\ContosoPizza.csproj", "{0815BE9C-C896-4269-AF9A-68F4D16FCDC9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C0557BC7-CFE0-4BFA-B1B7-3F52361E7449}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
8 changes: 4 additions & 4 deletions ContosoPizza/ContosoPizza.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
Expand All @@ -7,12 +7,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.12">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.6" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.10" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions ContosoPizza/ContosoPizza.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContosoPizza", "ContosoPizza.csproj", "{4E911496-4BAA-4D12-A3D7-1C7406135DB3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4E911496-4BAA-4D12-A3D7-1C7406135DB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E911496-4BAA-4D12-A3D7-1C7406135DB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E911496-4BAA-4D12-A3D7-1C7406135DB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E911496-4BAA-4D12-A3D7-1C7406135DB3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {89B2243D-F9DD-447A-B0D7-281E82281A57}
EndGlobalSection
EndGlobal
7 changes: 4 additions & 3 deletions ContosoPizza/Pages/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
ViewData["Title"] = "The Home for Pizza Lovers";
TimeSpan timeInBusiness = DateTime.Now - new DateTime(2018, 8, 14);
}

<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
<h1 class="display-4">Welcome to Contoso Pizza</h1>
<p class="lead">The best pizza in town for @Convert.ToInt32(timeInBusiness.TotalDays) days!</p>
</div>
10 changes: 10 additions & 0 deletions ContosoPizza/Pages/PizzaList.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@page
@model ContosoPizza.Pages.PizzaListModel
@{
ViewData["Title"] = "Pizza List 🍕";
}

<h1>Pizza List 🍕</h1>

<!-- New Pizza form will go here -->
<!-- List of pizzas will go here -->
12 changes: 12 additions & 0 deletions ContosoPizza/Pages/PizzaList.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace ContosoPizza.Pages
{
public class PizzaListModel : PageModel
{
public void OnGet()
{
}
}
}
3 changes: 3 additions & 0 deletions ContosoPizza/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/PizzaList">Pizza List 🍕</a>
</li>
</ul>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions ContosoPizza/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
builder.Services.AddRazorPages();
builder.Services.AddDbContext<PizzaContext>(options =>
options.UseSqlite("Data Source=ContosoPizza.db"));
builder.Services.AddScoped<PizzaService>();

var app = builder.Build();

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Welcome! This is the starter app for the [Create a web UI with ASP.NET Core](https://learn.microsoft.com/training/modules/create-razor-pages-aspnet-core/) Microsoft Training module.

## Developer Notes

dotnet watch run --project ContosoPizza

## Completed version

The completed version of this module is available on the `solution` branch of this repo.
Expand Down

0 comments on commit cdb82cd

Please sign in to comment.