Example #1
0
        public ServiceResult RegisterNewUser(UserRegistration user)
        {
            try
            {
                if (_dbHelper.UserExist(user.UserName))
                {
                    return(new ServiceResult("User with same name allready exist."));
                }

                user.Salt     = _encryptHelper.GeneratPaswordSalt();
                user.Password = _encryptHelper.GetHash(user.Salt + user.Password);

                if (!_dbHelper.AddNewUser(user))
                {
                    return(new ServiceResult("Failed to add new user."));
                }

                return(new ServiceResult(true));
            }
            catch (Exception ex)
            {
                // TO DO !!! Log appropriate message here !!!
                return(new ServiceResult(false));
            }
        }