Beispiel #1
0
        public void Vote(int pollId)
        {
            int sectionId = ctx.GetInt("sectionId");

            ContentPoll poll = pollService.GetById(pollId);

            if (poll == null)
            {
                actionContent(lang("exPollNotFound"));
                return;
            }

            ContentPost post = postService.GetById(poll.TopicId, ctx.owner.Id);

            if (post == null || post.PageSection.Id != sectionId)
            {
                actionContent(lang("exPollNotFound"));
                return;
            }

            if (poll.CheckHasVote(ctx.viewer.Id))
            {
                actionContent(alang("exVoted"));
                return;
            }

            String            choice = ctx.Get("pollOption");
            ContentPollResult pr     = new ContentPollResult();

            pr.User   = (User)ctx.viewer.obj;
            pr.PollId = poll.Id;
            pr.Answer = choice;
            pr.Ip     = ctx.Ip;

            //String lnkPoll = to( Show, poll.TopicId );
            String lnkPoll = alink.ToAppData(post);

            pollService.CreateResult(pr, lnkPoll);

            String url = to(VoteResult, poll.Id) + "?sectionId=" + sectionId;

            echoRedirect(alang("pollDone"), url);
        }
Beispiel #2
0
        public virtual void Vote(long id)
        {
            ContentPoll 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;
            }

            ContentPollResult pollResult = new ContentPollResult();

            pollResult.User   = (User)ctx.viewer.obj;
            pollResult.PollId = poll.Id;
            pollResult.Answer = choice;
            pollResult.Ip     = ctx.Ip;

            String lnkPost = to(new Content.PostController().Show, poll.TopicId);

            pollService.CreateResult(pollResult, lnkPost);

            echoAjaxOk();
        }
        public virtual void Vote( long id ) {

            ContentPoll 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;
            }

            ContentPollResult pollResult = new ContentPollResult();
            pollResult.User = (User)ctx.viewer.obj;
            pollResult.PollId = poll.Id;
            pollResult.Answer = choice;
            pollResult.Ip = ctx.Ip;

            String lnkPost = to( new Content.PostController().Show, poll.TopicId );
            pollService.CreateResult( pollResult, lnkPost );

            echoAjaxOk();
        }
        public void Vote( int pollId )
        {
            int sectionId = ctx.GetInt( "sectionId" );

            ContentPoll poll = pollService.GetById( pollId );
            if (poll == null) {
                actionContent( lang( "exPollNotFound" ) );
                return;
            }

            ContentPost post = postService.GetById( poll.TopicId, ctx.owner.Id );
            if (post == null || post.PageSection.Id != sectionId) {
                actionContent( lang( "exPollNotFound" ) );
                return;
            }

            if (poll.CheckHasVote( ctx.viewer.Id )) {
                actionContent( alang( "exVoted" ) );
                return;
            }

            String choice = ctx.Get( "pollOption" );
            ContentPollResult pr = new ContentPollResult();
            pr.User = (User)ctx.viewer.obj;
            pr.PollId = poll.Id;
            pr.Answer = choice;
            pr.Ip = ctx.Ip;

            //String lnkPoll = to( Show, poll.TopicId );
            String lnkPoll = alink.ToAppData( post );

            pollService.CreateResult( pr, lnkPoll );

            String url = to( VoteResult, poll.Id ) + "?sectionId=" + sectionId;

            echoRedirect( alang( "pollDone" ), url );
        }