public boolean isEditAuthorized() { Users user = ui.getUser(); boolean editAuthorized = false; if (user != null && recipe != null) { editAuthorized = recipe.getCreator().getUserName().equals(user.getUserName()) || ui.isIsAdmin(); } return editAuthorized; }
/** * Returns true if the user has already favorited this recipe, false otherwise * * @return true if already favorited, false otherwise */ public boolean isAlreadyFavorited() { if (ui.isIsUserAuthenticated()) { Users user = ui.getUser(); if (user.getFavorites() != null) { return user.getFavorites().contains(recipe); } else { return false; } } else { return false; } }
/** * returns true if it has been reviewed and false if it has not been reviewed by a professional; */ public boolean isHasAlreadyReviewed() { boolean result = false; if (ui.isIsUserAuthenticated() && professionalStatus.isIsProfessional()) { Users user = ui.getUser(); if (recipe != null) { for (Review rev : recipe.getReviews()) { if (rev.getReviewer().getUserName().equals(user.getUserName())) { result = true; break; } } // end for } } // end value != null return result; }