コード例 #1
0
ファイル: PollController.cs プロジェクト: youmuyou/wojilu
        public void Vote(int pollId)
        {
            PollData poll = pollService.GetById(pollId);

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

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

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

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

            String lnkPoll = to(Show, poll.Id);

            pollService.CreateResult(pr, lnkPoll);

            String url = to(Voter, poll.Id);

            echoRedirect(lang("pollDone"), url);
        }
コード例 #2
0
ファイル: PollController.cs プロジェクト: youmuyou/wojilu
        private void bindDetail(PollData poll)
        {
            set("post.Title", poll.Title);
            set("post.CreateTime", poll.Created);
            set("post.ReplyCount", poll.Replies);
            set("post.Hits", poll.Hits);

            User    user    = (User)ctx.viewer.obj;
            Boolean hasVote = poll.CheckHasVote(user.Id);

            ctx.SetItem("poll", poll);

            if (hasVote)
            {
                set("post.Content", loadHtml(sectionPollResult));
            }
            else
            {
                set("post.Content", loadHtml(sectionPoll));
            }
        }
コード例 #3
0
ファイル: PollController.cs プロジェクト: youmuyou/wojilu
        private void bindPollList(DataPage <PollData> polls)
        {
            User user = (User)ctx.viewer.obj;

            IBlock block = getBlock("list");

            for (int i = 0; i < polls.Results.Count; i++)
            {
                PollData poll = polls.Results[i];
                ctx.SetItem("poll", poll);

                block.Set("post.UserPic", poll.Creator.PicSmall);
                Boolean hasVote = poll.CheckHasVote(user.Id);
                String  html    = hasVote ? loadHtml(sectionPollResult) : loadHtml(sectionPoll);

                block.Set("post.Html", html);


                block.Next();
            }

            set("page", polls.PageBar);
        }