Search in sources :

Example 1 with Votable

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;
    }
}
Also used : Vote(org.mamute.model.Vote) Votable(org.mamute.model.interfaces.Votable)

Example 2 with Votable

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;
    }
}
Also used : Vote(org.mamute.model.Vote) Votable(org.mamute.model.interfaces.Votable)

Aggregations

Vote (org.mamute.model.Vote)2 Votable (org.mamute.model.interfaces.Votable)2