public async Task <ActionResult> Store(string username, string password) { var account = new Account() { UserName = username, Email = username, FirstName = "Xuan Bach", LastName = "Luong", Avatar = "avatar", Birthday = DateTime.Now, CreatedAt = DateTime.Now }; IdentityResult result = await _userManager.CreateAsync(account, password); if (result.Succeeded) { _userManager.AddToRole(account.Id, "User"); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await _userManager.GenerateEmailConfirmationTokenAsync(account.Id); await _userManager.SendEmailAsync(account.Id, "Hello world! Please confirm your account", "<b>Please confirm your account</b> by clicking <a href=\"http://google.com.vn\">here</a>"); return(RedirectToAction("Index", "Home")); } return(View("Register")); }
public async Task <ActionResult> ProcessRegister(string userName, string password, string email, string fullname, string phoneNumber) { var user = new User() { UserName = userName, Email = email, Name = fullname, PhoneNumber = phoneNumber, createdAt = DateTime.Now }; // success IdentityResult result = await _userManager.CreateAsync(user, password); if (result.Succeeded) { _userManager.AddToRole(user.Id, "User"); return(Redirect("/Home")); } return(Redirect("/Home")); }