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
No related branches found
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{
public boolean unlockSticker(String username, int packID, int stickerID){
/* Adds entry in the stickerprogress database, effectively unlocking the sticker for the user
* Returns false if no sticker is unlocked */
String query = "SELECT COUNT(id) FROM stickers WHERE (stickerID, packID) = (stickerID, packID)";
if (jdbc.queryForObject(query, Integer.class) == 1){ //Checks if sticker exists
String query = "SELECT COUNT(id) FROM stickers WHERE (stickerID, packID) = (?, ?)";
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 (?,?,?)";
jdbc.update(sql, username, packID, stickerID);
return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment