There was an error while loading. Please reload this page.
1 parent cbae84b commit 83c798dCopy full SHA for 83c798d
AspNetRunBasic/Pages/Product/Create.cshtml.cs
@@ -5,6 +5,7 @@
5
using AspNetRunBasic.Repositories;
6
using Microsoft.AspNetCore.Mvc;
7
using Microsoft.AspNetCore.Mvc.RazorPages;
8
+using Microsoft.AspNetCore.Mvc.Rendering;
9
10
namespace AspNetRunBasic.Pages.Product
11
{
@@ -23,5 +24,19 @@ public async Task<IActionResult> OnGetAsync()
23
24
ViewData["CategoryId"] = new SelectList(categories, "Id", "CategoryName");
25
return Page();
26
}
27
+
28
+ [BindProperty]
29
+ public Entities.Product Product { get; set; }
30
31
+ public async Task<IActionResult> OnPostAsync()
32
+ {
33
+ if (!ModelState.IsValid)
34
35
+ return Page();
36
+ }
37
38
+ Product = await _productRepository.AddAsync(Product);
39
+ return RedirectToPage("./Index");
40
41
42
0 commit comments