public async Task <IActionResult> Register([FromBody] RegisterViewModel registerViewModel) { if (!ModelState.IsValid) { NotifyModelStateErrors(); return(ResponseBadRequest()); } var user = _mapper.Map <User>(registerViewModel); var result = await _accessManager.CreateUser(user); if (result.Succeeded) { var token = await _accessManager.GenerateToken(user); return(Response(token)); } await AddIdentityErrors(result); return(ResponseBadRequest()); }