public async Task<IHttpActionResult> Register(RegistrationModel userModel) { // Validation if (!ModelState.IsValid) { return BadRequest(ModelState); } var result = await _repo.RegisterUser(userModel); IHttpActionResult errorResult = GetErrorResult(result); if (errorResult != null) { return errorResult; } return Ok(); }
//Adding Method to register user public async Task<IdentityResult> RegisterUser(RegistrationModel userModel) { //Instantiate new PropertyManagerUser PropertyManagerUser user = new PropertyManagerUser { UserName = userModel.EmailAddress, Email = userModel.EmailAddress, FirstName = userModel.FirstName, LastName = userModel.LastName, PhoneNumber = userModel.PhoneNumber }; //Creates user and stores password in encrypted format var result = await _userManager.CreateAsync(user, userModel.Password); return result; }