示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            errorPanel.Visible   = false;
            successPanel.Visible = false;

            string value = Request.QueryString["value"];

            if (value != null && value != string.Empty)
            {
                DAO.VotingFormBase dao = new DAO.VotingFormBase();

                if (dao.DetectPoll(value))
                {
                    PollBuilding exec = new PollBuilding();
                    Entity.Poll  poll = exec.RequestPoll(value);

                    if (poll != null)
                    {
                        #region PAGE BUILD

                        pollTitle.Text = poll.title;

                        StringBuilder sb = new StringBuilder();

                        sb.Append("<div class=\"list-group\">");

                        foreach (Entity.Option option in poll.pollOption)
                        {
                            sb.Append("<button onclick=\"SendVote(this);\" id=\"" + option.idOption + "\" name=\"option\" type=\"button\" class=\"list-group-item list-group-item-action d-flex justify-content-between align-items-center\" >" + option.question);
                            sb.Append("<span id=\"" + option.idOption + "b\" class=\"badge badge-primary badge-pill\" >" + option.votes + "</span>");
                            sb.Append("</button>");
                        }

                        sb.Append("</div>");

                        litOptions.Text = sb.ToString();

                        successPanel.Visible = true;

                        #endregion
                    }
                    else
                    {
                        errorMessage.Text  = "Failed to create poll";
                        errorPanel.Visible = true;
                    }
                }
                else
                {
                    errorMessage.Text  = "Poll not found";
                    errorPanel.Visible = true;
                }
            }
            else
            {
                errorMessage.Text  = "Invalid value";
                errorPanel.Visible = true;
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int    listVerification = 0;
            string link;

            List <string> values = new List <string>();

            foreach (string key in Request.Form.AllKeys)
            {
                if (key.StartsWith("option") && Request.Form[key].Length > 0)
                {
                    //Label1.Text += Request.Form[key] + "<br/>";

                    values.Add(Request.Form[key]);
                    listVerification++;
                }
            }

            if (values.Count > 2)
            {
                PollBuilding exec       = new PollBuilding();
                string       adressPoll = exec.BuildPoll(values);

                if (adressPoll != "error")
                {
                    link = adressPoll;
                }
                else
                {
                    link = "error";
                }
            }
            else
            {
                link = "error";
            }

            Response.Redirect("RequestPoll.aspx/?value=" + link);
        }