public async Task <IActionResult> UserRegistration(RegistrerUserDTO model) { if (ModelState.IsValid) { var user = _mapper.Map <AppUser>(model); IdentityResult result = await userManager.CreateAsync(user, model.Password); if (result.Succeeded) { await userManager.AddToRoleAsync(user, "user"); return(RedirectToAction("Login", "Auth")); } else { AddErrorsFromResult(result); } } return(View(model)); }
public async Task <IActionResult> CreateUser(RegistrerUserDTO model) { if (ModelState.IsValid) { AppUser user = new AppUser() { UserName = model.UserName, Email = model.Email }; IdentityResult result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { return(RedirectToAction(nameof(Users))); } else { AddErrorsFromResult(result); } } return(View(model)); }