public async Task <IActionResult> RegisterUser(RegisterUserViewModel model) { if (ModelState.IsValid) { Visitor visitor = new Visitor() { Email = model.Email }; _applicationService.AddVisitor(visitor); //_context.Visitors.Add(userData); //_context.SaveChanges(); var user = new ApplicationUser { UserName = model.Email, Email = model.Email, AccountType = "Restaurant", VisitorData = visitor }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=532713 // Send an email with this link //var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); //var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme); //await _emailSender.SendEmailAsync(model.Email, "Confirm your account", // "Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>"); await _signInManager.SignInAsync(user, isPersistent : false); _logger.LogInformation(3, "User created a new restaurant account with password."); return(RedirectToAction(nameof(HomeController.Index), "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }