public async Task <IActionResult> Login(AccountVM account, string returnUrl) { if (ModelState.IsValid) { if (account.Login != null) { var result = await _signInManager.PasswordSignInAsync(account.Login.UserName, account.Login.Password, account.Login.RememberMe, false); if (result.Succeeded) { if (!string.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("index", "home")); } } ModelState.AddModelError(string.Empty, "Ivalid Login atempt"); } else { User user = new User() { UserName = account.Signup.UserName, Email = account.Signup.Email, PasswordHash = account.Signup.Password }; var result = await _userManager.CreateAsync(user, account.Signup.Password); if (result.Succeeded) { Person person = new Person { UserKey = user.Id, FullName = "John Doe", PhoneNumber = "123456789", Age = 0, GenderKey = 1, CountryKey = 1, Address = "Unknown", BirthDate = new DateTime(1753, 1, 1), Proffesion = "Unknown", Education = "Unknown", AboutMe = "I am ..." }; operation.createPerson(person); return(View()); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } } return(View(account)); }