diff --git a/ContosoPizza/ContosoPizza.db b/ContosoPizza/ContosoPizza.db index a1f9119..2adbf98 100644 Binary files a/ContosoPizza/ContosoPizza.db and b/ContosoPizza/ContosoPizza.db differ diff --git a/ContosoPizza/ContosoPizza.db-shm b/ContosoPizza/ContosoPizza.db-shm new file mode 100644 index 0000000..fe9ac28 Binary files /dev/null and b/ContosoPizza/ContosoPizza.db-shm differ diff --git a/ContosoPizza/ContosoPizza.db-wal b/ContosoPizza/ContosoPizza.db-wal new file mode 100644 index 0000000..e69de29 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! +

diff --git a/ContosoPizza/Pages/PizzaList.cshtml b/ContosoPizza/Pages/PizzaList.cshtml new file mode 100644 index 0000000..b1f74e5 --- /dev/null +++ b/ContosoPizza/Pages/PizzaList.cshtml @@ -0,0 +1,75 @@ +@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) +
+ +
+
+ + +@section Scripts { + +} diff --git a/ContosoPizza/Pages/PizzaList.cshtml.cs b/ContosoPizza/Pages/PizzaList.cshtml.cs new file mode 100644 index 0000000..606b387 --- /dev/null +++ b/ContosoPizza/Pages/PizzaList.cshtml.cs @@ -0,0 +1,48 @@ +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(); + } + + [BindProperty] + public Pizza NewPizza { get; set; } = default!; + + public IActionResult OnPost() + { + if (!ModelState.IsValid || NewPizza == null) + { + return Page(); + } + + _service.AddPizza(NewPizza); + + return RedirectToAction("Get"); + } + + public IActionResult OnPostDelete(int id) + { + _service.DeletePizza(id); + + return RedirectToAction("Get"); + } + + + } +} 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 @@ +