Example #1
0
 public void FillForm(Poll poll)
 {
     nameInput.Value             = poll.Name;
     descriptionInput.Value      = poll.Description;
     dueDateInput.Date           = poll.DueDate.ToShortDateString();
     dueDateInput.DefaultView    = AjaxControlToolkit.CalendarDefaultView.Days;
     pollRadioList.SelectedIndex = (int)poll.Type;
     SessionUtilHelper.KeepPollQuestion(poll.Questions, Session);
     RefreshQuestionList(poll.Questions);
     activeCheck.Checked = poll.Active;
 }
Example #2
0
        protected void AddQuestion(object sender, EventArgs e)
        {
            //Prgeunta vacía...
            if (String.IsNullOrEmpty(questionInput.Value))
            {
                return;
            }

            List <PollOption> pollOptions     = new List <PollOption>();
            List <ListItem>   selectedOptions = optionListInput.Items.Cast <ListItem>().Where(li => li.Selected).ToList();

            //No se eligieron opciones
            if (selectedOptions.Count == 0)
            {
                return;
            }

            //Como es un elemento simple, no tiene sentido buscar el elemento en la base
            //puesto que todos los datos ya están disponibles.
            foreach (ListItem listItem in selectedOptions)
            {
                PollOption pollOption = new PollOption();
                pollOption.Id     = Convert.ToInt32(listItem.Value);
                pollOption.Option = listItem.Text;
                pollOptions.Add(pollOption);
            }

            PollQuestion pollQuestion = new PollQuestion();

            pollQuestion.Question = questionInput.Value;
            pollQuestion.Options  = pollOptions;

            SessionUtilHelper.KeepPollQuestion(pollQuestion, Session);
            RefreshQuestionList(SessionUtilHelper.GetPollQuestions(Session));

            questionInput.Value = "";
            optionListInput.ClearSelection();
        }