From 29a21d7baeff798e389b0065900d6541970369e4 Mon Sep 17 00:00:00 2001 From: Peace Date: Wed, 12 Jun 2024 12:02:34 +0900 Subject: [PATCH] post, delete --- WebUIWithRazor/ContosoPizza.db-shm | Bin 32768 -> 32768 bytes WebUIWithRazor/ContosoPizza.db-wal | Bin 0 -> 24752 bytes WebUIWithRazor/Pages/PizzaList.cshtml | 40 +++++++++++++++++++++-- WebUIWithRazor/Pages/PizzaList.cshtml.cs | 23 ++++++++++++- 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/WebUIWithRazor/ContosoPizza.db-shm b/WebUIWithRazor/ContosoPizza.db-shm index fe9ac2845eca6fe6da8a63cd096d9cf9e24ece10..5dc8b30383a9f728c1fc5adf42f7275dd5da92dd 100644 GIT binary patch delta 189 zcmZo@U}|V!s+V}A%K!pQK+MR%AixHsS%LV-+UXw*tu9*Wr@c`v>sDQx&dhq^H&gf* zQq=>E0t1k_|B(PxSdM`i%3=Z1Ad5jXoV~Fz+MAsbsD_1sZDZqiCT1oE){Twqh5+3L BEt>!U delta 89 zcmZo@U}|V!;+1%$%K!t66BkO0TChv7nNGgVi7uf4lYpuIj|Mg_4ENr+!O#Q%%H1CA diff --git a/WebUIWithRazor/ContosoPizza.db-wal b/WebUIWithRazor/ContosoPizza.db-wal index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..26e6ad00ba8b6a74f04025c898b7a7221efc35fd 100644 GIT binary patch literal 24752 zcmeI(KWGzC0LSrn`E%w9;W9MDm{J2096~O4(IR%NI=Bg?r3fO2p7G#l3fG8a5hPp3 z423!fDpb&dE{c;57A%B9>*yk;LlFlDK@bG*5fYl>6lh7p_i+c|UG8}KT&BnGcj1Bh zP!ztM6e1zyDBk&zySI|t`19GFx%stuBbbUDoWJtEG<$nL@hq-yiHP11`kvm?4fWkvJj5mlUyX{lEIUHh<1(=bmds>mzB13laK-CNnK%eLp* zi=k3*P2MKY&VIq)?+Y)RA12PkgGojIC4z&200IagfB*srAbfB*srAbt80tg_000IagfB*srATam>6HyuL*V5g% zf2;mB_#CoI=gu4EaqkQC^a$3UUw{1i#P5sr2nPRe#0n8W009ILKmY**5I_I{1Q6&) z;6RT+?g{kt2!5_^e4O5ywhr|O$P4rX%{>SpfB*srAbPizza 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"); + } } }