示例#1
0
        public bool CreateNewUser(TempEmployee temp)
        {
            if (PasswordUtils.IsPasswordFormatValid(temp.RawPw))
            {
                Employee newEmployee = temp;
                newEmployee.PwHash = PasswordUtils.Hash(temp.RawPw);

                var createUserQuery = $"INSERT INTO {DatabaseUtils.Databasename}.employeelist(EMP_Name_First, EMP_Name_Last, EMP_PW_Hash,EMP_Active, EMP_Type, EMP_PhoneNumber) " +
                                      $"VALUES('{newEmployee.FirstName}', '{newEmployee.LastName}','{newEmployee.PwHash}','1','{newEmployee.EmployeeType}',{newEmployee.PhoneNumber});";
                var createUser = DatabaseUtils.Instance();
                return(createUser.MakeDbQuery(createUserQuery));
            }
            return(false);
        }
示例#2
0
        public bool EditEmployeePW(Login updatedEmployee)
        {
            if (PasswordUtils.IsPasswordFormatValid(updatedEmployee.Password))
            {
                var passwordHash = PasswordUtils.Hash(updatedEmployee.Password);

                var updateEmployeeInfoQuery = $"UPDATE {DatabaseUtils.Databasename}.employeelist " +
                                              $"SET EMP_PW_Hash = '{passwordHash}' " +
                                              $"WHERE EMP_ID = '{updatedEmployee.Username}';";

                var updateEmployee = DatabaseUtils.Instance();
                return(updateEmployee.MakeDbQuery(updateEmployeeInfoQuery));
            }

            return(false);
        }