Esempio n. 1
0
 @Override
 public Response delScoreGame(String campusSession, String uidGame) {
   try {
     User objUser = sBo.validateSession(campusSession);
     if (objUser != null) {
       Game objGame = gBo.getGame(uidGame, null);
       GameScore objScore = scDao.getScoreGame(objGame.getIdGame(), objUser.getIdUser());
       scDao.delScoreGame(objScore);
     }
   } catch (Exception e) {
     e.printStackTrace();
     return Response.status(404).entity("ERROR SCORE DELETE").build();
   }
   return Response.status(200).entity("DEL SCORE OK").build();
 }
Esempio n. 2
0
  @Override
  public Response addScoreGame(String campusSession, String uidGame, String point) {
    try {
      User objUser = sBo.validateSession(campusSession);

      if (objUser != null) {
        Game objGame = gBo.getGame(uidGame, null);
        GameScore objScore = scDao.getScoreGame(objGame.getIdGame(), objUser.getIdUser());
        if (objScore == null) {
          objScore = new GameScore();
          objScore.setIdGame(objGame.getIdGame());
          objScore.setIdUser(objUser.getIdUser());
        }
        objScore.setPoints(Integer.parseInt(point));
        scDao.addScoreGame(objScore);
      }
    } catch (Exception e) {
      e.printStackTrace();
      return Response.status(404).entity("ERROR SCORE SAVE").build();
    }
    return Response.status(200).entity("ADD SCORE OK").build();
  }
Esempio n. 3
0
  @Override
  public List<Score> listScoreGames(String uidGame) {

    Game objGame = gBo.getGame(uidGame, null);

    ArrayList<Score> arrayList = new ArrayList<Score>();
    if (objGame != null) {
      List<GameScore> listScore = scDao.getAllScoreGame(objGame.getIdGame());
      for (int i = 0; i < listScore.size(); i++) {
        GameScore objGameScore = listScore.get(i);
        Score objScore = new Score();
        objScore.setPoints(objGameScore.getPoints());
        objScore.setNameUser(uDao.getUser(objGameScore.getIdUser()).getLogin());
        arrayList.add(objScore);
      }
    }
    return arrayList;
  }