Exemple #1
0
  /**
   * updateUser Updates a user in the database.
   *
   * @param newUser The user instance to be updated.
   * @return Returns true or false if the user was updated or not.
   */
  @Override
  public boolean updateUser(User newUser) {
    // format the string
    String query =
        "UPDATE Users SET Email = '%1$s', FacebookID = '%2$s', Username = '******', RoleID = %4$d, Status = %5$d, Fullname = '%7$s' WHERE UserID = %6$d";

    query =
        String.format(
            query,
            newUser.getEmail(),
            newUser.getFacebookID(),
            newUser.getUsername(),
            newUser.getRoleID(),
            (newUser.getStatus() ? 0 : 1),
            newUser.getUserID(),
            newUser.getFullname());

    // if everything worked, inserted id will have the identity key
    // or primary key
    return DataService.executeUpdate(query);
  }
Exemple #2
0
 /**
  * deleteUser Deletes a user from the database.
  *
  * @param oldUser The user instance to be deleted.
  * @return Returns true if the user was deleted and false if the user was not deleted.
  */
 @Override
 public boolean deleteUser(User oldUser) {
   return deleteUser(oldUser.getUserID());
 }