Closed tarek4489 closed 4 years ago
The error
The code
public class SetorsController : Controller { private readonly ApplicationDbContext _context; private ApplicationDbContext context;
public SetorsController(ApplicationDbContext context) { this.context = context; } // GET: Admin/Setors [HttpGet] public async Task<IActionResult> Cadastrar() { RegisterViewModel model = new RegisterViewModel() { SetoresList = await context.Setores.ToListAsync(), UnidadesList = await context.Unidades.ToListAsync() }; return View(); } private readonly UserManager<IdentityUser> userManager; private readonly SignInManager<IdentityUser> signInManager; public SetorsController(UserManager<IdentityUser> userManager, SignInManager<IdentityUser> signInManager) { this.userManager = userManager; this.signInManager = signInManager; } private RegisterViewModel RegisterViewModel() { throw new NotImplementedException(); } [HttpPost] [ValidateAntiForgeryToken] public async Task<IActionResult> Cadastrar(RegisterViewModel model) { if (ModelState.IsValid) { var user = new IdentityUser { UserName = model.Email, Email = model.Email }; var result = await userManager.CreateAsync(user, model.Password); if (result.Succeeded) { await signInManager.SignInAsync(user, isPersistent: false); return RedirectToAction("index", "home"); } foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } } return View(model); }
Get new source, should be fixed now.
The error
The code
public class SetorsController : Controller { private readonly ApplicationDbContext _context; private ApplicationDbContext context;