public void Vote(int id) { ForumPoll poll = pollService.GetById(id); if (poll == null) { echoError(lang("exPollItemNotFound")); return; } if (poll.CheckHasVote(ctx.viewer.Id)) { echoError(lang("exVoted")); return; } String choice = ctx.Post("pollOption"); if (strUtil.IsNullOrEmpty(choice)) { echoError(lang("pollSelectRequire")); return; } ForumPollResult pollResult = new ForumPollResult(); pollResult.User = (User)ctx.viewer.obj; pollResult.PollId = poll.Id; pollResult.Answer = choice; pollResult.Ip = ctx.Ip; String lnkPost = to(new Forum.TopicController().Show, poll.TopicId); pollService.CreateResult(pollResult, lnkPost); echoAjaxOk(); }
public void Vote(int id) { ForumPoll poll = pollService.GetById(id); if (poll == null) { echoText(alang("exPollItemNotFound")); return; } if (poll.CheckHasVote(ctx.viewer.Id)) { echoText(alang("exVoted")); return; } String choice = ctx.Get("pollOption"); ForumPollResult pollResult = new ForumPollResult(); pollResult.User = (User)ctx.viewer.obj; pollResult.PollId = poll.Id; pollResult.Answer = choice; pollResult.Ip = ctx.Ip; String lnkPost = to(new Forum.TopicController().Show, poll.TopicId); pollService.CreateResult(pollResult, lnkPost); ForumBoard board = setCurrentBoard(poll); String lnkVote = to(Vote, id) + "?boardId=" + board.Id; String lnkVoter = to(Voter, id) + "?boardId=" + board.Id; String json = new PollViewFactory((User)ctx.viewer.obj, poll, lnkVote, lnkVoter).GetJsonResult(); echoText(json); }
public void Vote( int id ) { ForumPoll poll = pollService.GetById( id ); if (poll == null) { echoText( alang( "exPollItemNotFound" ) ); return; } if (poll.CheckHasVote( ctx.viewer.Id )) { echoText( alang( "exVoted" ) ); return; } String choice = ctx.Get( "pollOption" ); ForumPollResult pollResult = new ForumPollResult(); pollResult.User = (User)ctx.viewer.obj; pollResult.PollId = poll.Id; pollResult.Answer = choice; pollResult.Ip = ctx.Ip; String lnkPost = to( new Forum.TopicController().Show, poll.TopicId ); pollService.CreateResult( pollResult, lnkPost ); ForumBoard board = setCurrentBoard( poll ); String lnkVote = to( Vote, id ) + "?boardId=" + board.Id; String lnkVoter = to( Voter, id ) + "?boardId=" + board.Id; String json = new PollViewFactory( (User)ctx.viewer.obj, poll, lnkVote, lnkVoter ).GetJsonResult(); echoText( json ); }
public void Vote( int id ) { ForumPoll poll = pollService.GetById( id ); if (poll == null) { echoError( lang( "exPollItemNotFound" ) ); return; } if (poll.CheckHasVote( ctx.viewer.Id )) { echoError( lang( "exVoted" ) ); return; } String choice = ctx.Post( "pollOption" ); if (strUtil.IsNullOrEmpty( choice )) { echoError( lang( "pollSelectRequire" ) ); return; } ForumPollResult pollResult = new ForumPollResult(); pollResult.User = (User)ctx.viewer.obj; pollResult.PollId = poll.Id; pollResult.Answer = choice; pollResult.Ip = ctx.Ip; String lnkPost = to( new Forum.TopicController().Show, poll.TopicId ); pollService.CreateResult( pollResult, lnkPost ); echoAjaxOk(); }