forked from Sarah/Lieb-Website
Created database
This commit is contained in:
parent
e068536abe
commit
eec8e419ba
19 changed files with 618 additions and 4 deletions
45
Lieb/Pages/Users/Create.cshtml.cs
Normal file
45
Lieb/Pages/Users/Create.cshtml.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
#nullable disable
|
||||
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 Lieb.Data;
|
||||
using Lieb.Models;
|
||||
|
||||
namespace Lieb.Pages.Users
|
||||
{
|
||||
public class CreateModel : PageModel
|
||||
{
|
||||
private readonly Lieb.Data.LiebContext _context;
|
||||
|
||||
public CreateModel(Lieb.Data.LiebContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public User User { get; set; }
|
||||
|
||||
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
_context.Users.Add(User);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToPage("./Index");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue