public async Task <IActionResult> Register(LoginVM loginVm) { if (ModelState.IsValid) { var identityUser = Transformation.Convert <LoginVM, IdentityUser>(loginVm); var result = await _userManagementBs.Register(identityUser, loginVm.Password); if (result.Succeeded) { return(RedirectToAction("Index", "Home")); } } return(View(loginVm)); }
public async Task <IActionResult> Add(UserVM userVm) { if (!ModelState.IsValid) { return(View(userVm)); } var identityUser = Transformation.Convert <UserVM, IdentityUser>(userVm); IdentityResult result = await _userManagementBs.Register(identityUser, userVm.Password); if (result.Succeeded) { return(RedirectToAction("Index")); } foreach (IdentityError error in result.Errors) { ModelState.AddModelError("", error.Description); } return(View("_Add", userVm)); }