private void HandleSignupCompleted(object sender, SignupResultModel e){

		}
Exemplo n.º 2
0
        public SignupResultModel SignupStandardUser(UserModel user)
        {
            SignupResultModel model = new SignupResultModel();

            string cmd = "INSERT INTO USERS(GlobalID, UserID, LoginType, Password, FirstName, LastName, CreateDate, IsActivated)";
            cmd += "VALUES(@GlobalID, @UserID, @LoginType, @Password, @FirstName, @LastName, @CreateDate, @IsActivated)";

            SqlParameter globalid = new SqlParameter("@GlobalID", user.GlobalID);
            SqlParameter userid = new SqlParameter("@UserID", user.UserID);
            SqlParameter userlogintype = new SqlParameter("@LoginType", user.UserLoginType);
            SqlParameter password = new SqlParameter("@Password", user.PasswordHash);
            SqlParameter fname = new SqlParameter("@FirstName", user.FirstName);
            SqlParameter lname = new SqlParameter("@LastName", user.LastName);
            SqlParameter createdate = new SqlParameter("@CreateDate", user.CreateDate);
            SqlParameter isactive = new SqlParameter("@IsActivated", user.IsActivated);

            try
            {
                //- check if user exists
                bool doesExist = CheckUserExists(user.UserID);

                if (doesExist)
                {
                    model.ResultStatus = SignupResultType.UserExists;
                    model.Message = "The user id already exists";
                    return model;
                }

                // - insert new user into database
                int queryresult = DatabaseHelper.ExecuteNonQuery(cmd, _connectionString,
                    globalid, userid, userlogintype, password, fname, lname, createdate, isactive);

                if (queryresult < 0)
                {
                    model.ResultStatus = SignupResultType.UnexpectedException;
                    model.Message = "The database was unable to add the user record";
                }
                else
                {
                    model.ResultStatus = SignupResultType.Success;
                    model.Message = "User account successfully added";
                }
            }
            catch (Exception ex)
            {
                LogMessageModel message = new LogMessageModel(LogStatus.Error,
                    string.Format("An error occurred during user signup within DatabaseManager.SignupStandardUser: {0}", ex.Message), -1);

                model.ResultStatus = SignupResultType.UnexpectedException;
                model.Message = string.Format("An exception occurred while attempted to add the user account: {0}", ex.Message);
            }

            return model;
        }