I'm trying to add a controller for the ApplicationUser.cs so that when a admin is logged in, they have the ability to view, edit, delete any records from the dbo.AspNetUsers table however I think I'm doing it wrong. This run with Error "NullReferenceException: Object reference not set to an instance of an object."Any idea?
AdminController:
public AdminController (ApplicationDbContext application)
{
_application = application;
[HttpGet]
public IActionResult ActiveUser() { return View();}
[HttpPost]
public async Task<ActionResult> ActiveUser(ApplicationUser Model)
{
var active = await _application.Users.FindAsync(Model.Email);
Model.IsActive = true;
active.IsActive = (Model.IsActive==true);
await _application.SaveChangesAsync();
return View();
}
View : ` @model ApplicationUser
<input asp-for="IsActive" class="form-control" />
<span asp-validation-for="IsActive" class="text-danger"></span>
</div>
<button type="submit" class="btn btn-success">ok</button>`