diff --git a/WebUIWithRazor/ContosoPizza.db-shm b/WebUIWithRazor/ContosoPizza.db-shm index fe9ac28..5dc8b30 100644 Binary files a/WebUIWithRazor/ContosoPizza.db-shm and b/WebUIWithRazor/ContosoPizza.db-shm differ diff --git a/WebUIWithRazor/ContosoPizza.db-wal b/WebUIWithRazor/ContosoPizza.db-wal index e69de29..26e6ad0 100644 Binary files a/WebUIWithRazor/ContosoPizza.db-wal and b/WebUIWithRazor/ContosoPizza.db-wal differ diff --git a/WebUIWithRazor/Pages/PizzaList.cshtml b/WebUIWithRazor/Pages/PizzaList.cshtml index 6925400..59346e5 100644 --- a/WebUIWithRazor/Pages/PizzaList.cshtml +++ b/WebUIWithRazor/Pages/PizzaList.cshtml @@ -6,6 +6,38 @@

Pizza List 🍕

+
+
+
+ + + +
+
+ + + +
+
+ +
+
+ + + +
+
+ +
+
+ @@ -25,11 +57,15 @@ } -
@pizza.Size @(pizza.IsGlutenFree ? "✔️" : string.Empty) -
+
\ No newline at end of file + + +@section Scripts { + +} \ No newline at end of file diff --git a/WebUIWithRazor/Pages/PizzaList.cshtml.cs b/WebUIWithRazor/Pages/PizzaList.cshtml.cs index 636ba71..3587a98 100644 --- a/WebUIWithRazor/Pages/PizzaList.cshtml.cs +++ b/WebUIWithRazor/Pages/PizzaList.cshtml.cs @@ -8,7 +8,10 @@ namespace ContosoPizza.Pages public class PizzaListModel : PageModel { private readonly PizzaService _service; - public IList PizzaList { get; set; } = default; + public IList PizzaList { get; set; } = new List(); + + [BindProperty] + public Pizza NewPizza { get; set; } = default; public PizzaListModel(PizzaService service) { @@ -19,5 +22,23 @@ namespace ContosoPizza.Pages { PizzaList = _service.GetPizzas(); } + + public IActionResult OnPost() + { + if (ModelState.IsValid && NewPizza != null) + { + _service.AddPizza(NewPizza); + + } + + return RedirectToAction("Get"); + } + + public IActionResult OnPostDelete(int id) + { + _service.DeletePizza(id); + + return RedirectToAction("Get"); + } } }