using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.Rendering; using CertAuth.Data; using CertAuth.Domain; namespace CertAuthAdmin.Pages.Users { public class AddNewEFModel : PageModel { private readonly CertAuth.Data.CertAuthContext _context; public AddNewEFModel(CertAuth.Data.CertAuthContext context) { _context = context; } public IActionResult OnGet() { return Page(); } [BindProperty] public User User { get; set; } // To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task OnPostAsync() { if (!ModelState.IsValid) { return Page(); } _context.Users.Add(User); await _context.SaveChangesAsync(); return RedirectToPage("./Index"); } } }