public async Task <IActionResult> Login([FromBody] UserParams userParams) { var result = await _repo.Login(userParams); if (result.SignInResult.Succeeded) { var response = new ResponseToReturnDto { Result = "success", Data = _mapper.Map <UserToReturnDto>(result.Data) }; return(Ok(response)); } else { return(BadRequest(_mapper.Map <ErrorToReturnDto>(IdentityErrors.HandleErrors(result.SignInResult)))); } }
public async Task <IActionResult> Register([FromBody] UserParams userParams) { var result = await _repo.Register(userParams); if (result.Succeeded) { var user = await _repo.GetUserByName(userParams.UserName); var response = new ResponseToReturnDto { Result = "success", Data = _mapper.Map <UserToReturnDto>(user) }; return(Ok(response)); } else { return(BadRequest(_mapper.Map <ErrorToReturnDto>(IdentityErrors.HandleErrors(result.Errors)))); } }