From cd99342046c5299bc27346d6b940faac9e337cef Mon Sep 17 00:00:00 2001 From: N2SuccessAll Date: Mon, 29 Apr 2024 16:43:59 +0100 Subject: [PATCH 1/2] Modify the Home Page. --- ContosoPizza/Pages/Index.cshtml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ContosoPizza/Pages/Index.cshtml b/ContosoPizza/Pages/Index.cshtml index b5f0c15..2094927 100644 --- a/ContosoPizza/Pages/Index.cshtml +++ b/ContosoPizza/Pages/Index.cshtml @@ -1,10 +1,13 @@ @page @model IndexModel @{ - ViewData["Title"] = "Home page"; + ViewData["Title"] = "The Home for Pizza Lovers"; + TimeSpan timeInBusiness = DateTime.Now - new DateTime(2018, 8, 14); }
-

Welcome

-

Learn about building Web apps with ASP.NET Core.

+

Welcome to Contoso Pizza

+

+ The best pizza in town for @Convert.ToInt32(timeInBusiness.TotalDays) days! +

From 05267f9f8aa85a1f156f15b25a11db883fc79e1f Mon Sep 17 00:00:00 2001 From: N2SuccessAll Date: Tue, 30 Apr 2024 12:29:58 +0100 Subject: [PATCH 2/2] Create and add Pizza List. --- ContosoPizza/Pages/PizzaList.cshtml | 38 ++++++++++++++++++++++++ ContosoPizza/Pages/PizzaList.cshtml.cs | 24 +++++++++++++++ ContosoPizza/Pages/Shared/_Layout.cshtml | 10 +++++-- ContosoPizza/Program.cs | 1 + 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 ContosoPizza/Pages/PizzaList.cshtml create mode 100644 ContosoPizza/Pages/PizzaList.cshtml.cs diff --git a/ContosoPizza/Pages/PizzaList.cshtml b/ContosoPizza/Pages/PizzaList.cshtml new file mode 100644 index 0000000..83e06b1 --- /dev/null +++ b/ContosoPizza/Pages/PizzaList.cshtml @@ -0,0 +1,38 @@ +@page +@model ContosoPizza.Pages.PizzaListModel +@{ + ViewData["Title"] = "Pizza List 🍕"; +} + +

Pizza List 🍕

+ + + + + + + + + + + + + + + + @foreach (var pizza in Model.PizzaList) + { + + + + + + + + } + +
NamePriceSizeGluten FreeDelete
@pizza.Name@($"{pizza.Price:C}")@pizza.Size@(pizza.IsGlutenFree ? "✔️" : string.Empty) +
+ +
+
diff --git a/ContosoPizza/Pages/PizzaList.cshtml.cs b/ContosoPizza/Pages/PizzaList.cshtml.cs new file mode 100644 index 0000000..8d152b3 --- /dev/null +++ b/ContosoPizza/Pages/PizzaList.cshtml.cs @@ -0,0 +1,24 @@ +using ContosoPizza.Models; +using ContosoPizza.Services; + +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace ContosoPizza.Pages +{ + public class PizzaListModel : PageModel + { + private readonly PizzaService _service; + public IList PizzaList { get; set; } = default!; + + public PizzaListModel(PizzaService service) + { + _service = service; + } + + public void OnGet() + { + PizzaList = _service.GetPizzas(); + } + } +} diff --git a/ContosoPizza/Pages/Shared/_Layout.cshtml b/ContosoPizza/Pages/Shared/_Layout.cshtml index ff24a5c..0629740 100644 --- a/ContosoPizza/Pages/Shared/_Layout.cshtml +++ b/ContosoPizza/Pages/Shared/_Layout.cshtml @@ -1,5 +1,6 @@  + @@ -8,13 +9,14 @@ +