/** * Wrapper method that saves photo. If photo exists, it updates existing photo. If photo doesn't * exist, it makes new photo. * * @param photo * @return true if it is added/updated correctly. false if there is an exception. */ public boolean savePhoto(Photo photo) { try { if (photo.getId() == 0) { return db.addPhoto(photo) != -1; } else { return db.updatePhoto(photo) > 0; } } catch (Exception e) { return false; } }
/** * Wrapper method that deletes photo by primary key. * * @param id * @return true if it is deleted correctly. False if there is an exception. */ public boolean deletePhoto(int id) { try { return db.deletePhoto(id) > 0; } catch (Exception e) { return false; } }
/** * Gets photo by primary id * * @param id * @return */ public Photo getPhotoById(int id) { return db.getPhoto(id); }