Ejemplo n.º 1
0
        /// <summary>
        /// Creates and returns new user
        /// </summary>
        /// <param name="userInput">User info</param>
        /// <returns>created user or exception</returns>
        public async Task <UserCompleteDTO> CreateNewUser(UserRegisterDTO userInput)
        {
            if (UserDBContext.EmailExists(userInput.Email))
            {
                userInput.Password = PasswordHasher.HashPassword(userInput.Password);
                if (userInput.Image == null)
                {
                    userInput.Image = Constants.DEFAULT_USER_IMAGE;
                }
                Guid ID = await UserDBContext.CreateNewUser(userInput);

                UserCompleteDTO user;
                user    = UserMapper.Map <UserRegisterDTO, UserCompleteDTO>(userInput);
                user.ID = ID;
                return(user);
            }
            else
            {
                throw new Exceptions.AlreadyExistsException("Email address already in use");
            }
        }