Beispiel #1
0
        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());
        }
Beispiel #2
0
 public void UpdateUser(UserDto user)
 {
     _userRepository.UpdateUser(user.CreateEntity());
 }
Beispiel #3
0
 public int CreateUser(UserDto user)
 {
     return(_userRepository.CreateUser(user.CreateEntity()));
 }