Esempio n. 1
0
        public void PopulateModel(Poll poll)
        {
            poll.Name        = nameInput.Value;
            poll.Description = descriptionInput.Value;
            poll.DueDate     = String.IsNullOrEmpty(dueDateInput.Date)? DateTime.Now :  Convert.ToDateTime(dueDateInput.Date);
            poll.Active      = activeCheck.Checked;
            Poll.PollType type;
            Enum.TryParse <Poll.PollType>(pollRadioList.SelectedItem.Value, true, out type);
            poll.Type = type;

            //Es un manejo malo... pero se eliminan todas las preguntas de la lista porque
            //se recibe el listado actualizado de la sesión
            poll.Questions = new List <PollQuestion>();

            //Es un chinito: si no se editaron, no se debe llenar la lista
            if (SessionUtilHelper.PollQuestionEdited())
            {
                poll.Questions.AddRange(SessionUtilHelper.GetPollQuestions(Session));
            }
            else
            {
                poll.Questions = null;
            }
            SessionUtilHelper.FlushPollQuestion(Session);
        }
Esempio n. 2
0
        /// <summary>
        /// Elimina de la lista de las preguntas, aquella que se encuentra seleccionada.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DeleteQuestion(object sender, EventArgs e)
        {
            if (pollQuestionList.SelectedItem == null)
            {
                return;
            }
            ListItem     selectedQuestion = pollQuestionList.SelectedItem;
            PollQuestion pollQuestion     = new PollQuestion();

            pollQuestion.Question = selectedQuestion.Text;
            SessionUtilHelper.RemovePollQuestion(pollQuestion, Session);
            RefreshQuestionList(SessionUtilHelper.GetPollQuestions(Session));
        }
Esempio n. 3
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();
        }