private static RegisterViewModel[] GetUsers() { var users = new RegisterViewModel[] { new RegisterViewModel { Email = "*****@*****.**", Password = "******", ConfirmPassword = "******" }, new RegisterViewModel { Email = "*****@*****.**", Password = "******", ConfirmPassword = "******" }, new RegisterViewModel { Email = "*****@*****.**", Password = "******", ConfirmPassword = "******" }, }; return users; }
public async Task<IActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.UserName }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent: false); return RedirectToAction("Index", "Home"); } else { AddErrors(result); } } // If we got this far, something failed, redisplay form return View(model); }