use of org.mamute.model.interfaces.Votable in project mamute by caelum.
the class VoteController method tryToRemoveVoteVotable.
@SuppressWarnings("rawtypes")
private void tryToRemoveVoteVotable(Long id, VoteType voteType, Class votableType) {
try {
Votable votable = votes.loadVotable(votableType, id);
Vote current = new Vote(currentUser.getCurrent(), voteType);
votingMachine.unRegister(votable, current, votableType);
// votes.save(current);
result.use(Results.json()).withoutRoot().from(votable.getVoteCount()).serialize();
} catch (IllegalArgumentException e) {
result.use(Results.http()).sendError(409);
return;
}
}
use of org.mamute.model.interfaces.Votable in project mamute by caelum.
the class VoteController method tryToVoteVotable.
@SuppressWarnings("rawtypes")
private void tryToVoteVotable(Long id, VoteType voteType, Class votableType) {
try {
Votable votable = votes.loadVotable(votableType, id);
Vote current = new Vote(currentUser.getCurrent(), voteType);
votingMachine.register(votable, current, votableType);
votes.save(current);
result.use(Results.json()).withoutRoot().from(votable.getVoteCount()).serialize();
} catch (IllegalArgumentException e) {
result.use(Results.http()).sendError(409);
return;
}
}