public async Task <IActionResult> Signup([FromBody] UserDto userDto) { // validate request if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (userDto == null) { return(BadRequest("Invalid client request")); } userDto.Username = userDto.Username.ToLower(); // we store username only in lowercase if (await _repository.UserExists(userDto.Username)) { return(BadRequest(string.Format("User with username '{0}' already exists.", userDto.Username))); } else { User userEntity = UserDto.CreateEntity(userDto); var result = _repository.Register(userEntity, userDto.Password); } return(Ok()); }
public void UpdateUser(UserDto user) { _userRepository.UpdateUser(user.CreateEntity()); }
public int CreateUser(UserDto user) { return(_userRepository.CreateUser(user.CreateEntity())); }