protected void LinkButtonSaveQuestion_Click(object sender, EventArgs e)
 {
     using (PollSystemEntities context = new PollSystemEntities())
     {
         Question question;
         if (isNewQuestion)
         {
             question = new Question();
             context.Questions.Add(question);
         }
         else
         {
             question = context.Questions.Find(this.questionId);
         }
         question.QuestionText = this.TextBoxQuestionText.Text;
         try
         {
             context.SaveChanges();
             ErrorSuccessNotifier.AddInfoMessage("Question " +
                 (this.isNewQuestion ? "created." : "edited."));
             if (isNewQuestion)
             {
                 ErrorSuccessNotifier.ShowAfterRedirect = true;
                 Response.Redirect("EditQuestion.aspx?questionId=" + 
                     question.QuestionId, false);
             }
         }
         catch (Exception ex)
         {
             ErrorSuccessNotifier.AddErrorMessage(ex);
         }
     }
 }
        protected void ButtonSaveQuestionText_Click(object sender, EventArgs e)
        {
            using (var context = new PollSystemEntities())
            {
                Question question = null;
                if (this.questionId == 0) // Creating a new question
                {
                    question = new Question();
                    context.Questions.Add(question);
                }
                else // Editing an existing question
                {
                    question = context.Questions.FirstOrDefault(q => q.QuestionId == this.questionId);
                    if (question == null)
                    {
                        ErrorSuccessNotifier.AddErrorMessage(
                            "An unexpected error occured! The question you want to edit was not found!");
                        return;
                    }
                }

                try
                {
                    question.QuestionText = this.TextBoxQuestionText.Text;
                    context.SaveChanges();

                    ErrorSuccessNotifier.AddSuccessMessage("Question successfully " +
                        (this.questionId == 0 ? "created!" : "edited!"));
                    ErrorSuccessNotifier.ShowAfterRedirect = true;

                    this.Response.Redirect("InsertEditQuestions.aspx", false);
                }
                catch (Exception exc)
                {
                    ErrorSuccessNotifier.AddErrorMessage(exc);
                    return;
                }
            }
        }