public async Task <IActionResult> Register([FromForm] UserCreateViewModel inputModel) { if (ModelState.IsValid) { var doesUserExist = await _userManager.FindByEmailAsync(inputModel.User.EmailAddress); if (doesUserExist == null) { var guidId = Guid.NewGuid(); var userId = guidId.ToString(); var registerUser = new UserDTO() { UserId = userId, FirstName = inputModel.User.FirstName, LastName = inputModel.User.LastName, EmailAddress = inputModel.User.EmailAddress, Password = inputModel.User.Password }; await _userServiceAPI.RegisterUser(registerUser); var identityUser = new ApplicationUser() { Id = registerUser.UserId, UserName = registerUser.EmailAddress, Email = registerUser.EmailAddress, }; var createResult = await _userManager.CreateAsync(identityUser, registerUser.Password); if (!createResult.Succeeded) { ModelState.AddModelError("", "Could not create identity user"); return(View("Index")); } } else { ModelState.AddModelError("", "A user is already registered with that email."); return(View("Create", inputModel)); } return(RedirectToAction("Index", "UserLogin")); } else { return(View("Create", inputModel)); } }
public async Task RegisterUser(UserDTO registerUser) { await _restClient.RegisterUser(registerUser); }