Skip to content
Snippets Groups Projects
Commit 90b36806 authored by Gabriel Copat's avatar Gabriel Copat
Browse files

Fixed reported issue with UnlockSticker method

parent 33a78976
Branches
No related tags found
1 merge request!37Resolve "As a repeat trail visitor , I want to be able to create an account so I can save and review my progress."
...@@ -50,8 +50,11 @@ public class UserRepositoryJDBC implements UserRepository{ ...@@ -50,8 +50,11 @@ public class UserRepositoryJDBC implements UserRepository{
public boolean unlockSticker(String username, int packID, int stickerID){ public boolean unlockSticker(String username, int packID, int stickerID){
/* Adds entry in the stickerprogress database, effectively unlocking the sticker for the user /* Adds entry in the stickerprogress database, effectively unlocking the sticker for the user
* Returns false if no sticker is unlocked */ * Returns false if no sticker is unlocked */
String query = "SELECT COUNT(id) FROM stickers WHERE (stickerID, packID) = (stickerID, packID)"; String query = "SELECT COUNT(id) FROM stickers WHERE (stickerID, packID) = (?, ?)";
if (jdbc.queryForObject(query, Integer.class) == 1){ //Checks if sticker exists
int stickerCount = jdbc.queryForObject(query, Integer.class, stickerID, packID);
if (stickerCount == 1){ //Checks if sticker exists
String sql = "INSERT INTO stickerprogress (username, packID, stickerID) VALUES (?,?,?)"; String sql = "INSERT INTO stickerprogress (username, packID, stickerID) VALUES (?,?,?)";
jdbc.update(sql, username, packID, stickerID); jdbc.update(sql, username, packID, stickerID);
return true; return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment