/// <summary>
        /// Generate URLs of the <paramref name="lastStrawPoll"/> using its <paramref name="ID"/>
        /// and insert them in database
        /// </summary>
        /// <remarks>It ain't creating a new strawpoll, the concerned strawpoll is updated</remarks>
        /// <param name="lastStrawPoll">The strawpoll object holding the URLs</param>
        /// <param name="ID">The ID of the strawpoll</param>
        public void sendURLsInDataBase(Models.StrawPoll lastStrawPoll, int ID)
        {
            String          queryAddURLs;
            ConnectionQuery newDataBaseTask = new ConnectionQuery();

            String URLStrawPoll = lastStrawPoll.generateURLStrawPoll(ID);

            lastStrawPoll.setURLStrawPoll(URLStrawPoll);

            String URLDeletion = lastStrawPoll.generateURLDeletion();

            lastStrawPoll.setURLDeletion(URLDeletion);

            String URLResult = lastStrawPoll.generateURLResults(ID);

            lastStrawPoll.setURLResults(URLResult);

            queryAddURLs = "UPDATE StrawPoll " +
                           "SET URLStrawPoll = @URLStrawPoll, URLDeletion = @URLDeletion, URLResult = @URLResult, IsActive = @IsActive " +
                           "WHERE NumStrawPoll=@ID";

            newDataBaseTask.OpenConnection();

            SqlCommand cmd = new SqlCommand(queryAddURLs, newDataBaseTask.getSqlConnection());

            cmd.Parameters.AddWithValue("@URLStrawPoll", URLStrawPoll);
            cmd.Parameters.AddWithValue("@URLDeletion", URLDeletion);
            cmd.Parameters.AddWithValue("@URLResult", URLResult);
            cmd.Parameters.AddWithValue("@IsActive", true);
            cmd.Parameters.AddWithValue("@ID", ID);

            newDataBaseTask.setMySqlCommand(cmd);
            newDataBaseTask.ExecuteNonQuery();
            newDataBaseTask.CloseConnection();
        }
        /// <summary>
        /// Insert the <paramref name="newAnswer"/> in database
        /// </summary>
        /// <param name="newAnswer">The answer object to insert</param>
        /// <param name="ID">The ID of the strawpoll linked with this answer</param>
        public void sendAnswerInDatabase(Models.Answer newAnswer, int ID)
        {
            String          queryAddAnswer;
            ConnectionQuery newDataBaseTask = new ConnectionQuery();

            queryAddAnswer = "INSERT INTO Answer(Answer, NbrVotes, NumStrawPoll) " +
                             "VALUES(@Answer, @NbrVotes, @NumStrawPoll)";

            newDataBaseTask.OpenConnection();

            SqlCommand cmd = new SqlCommand(queryAddAnswer, newDataBaseTask.getSqlConnection());

            cmd.Parameters.AddWithValue("@Answer", newAnswer.getAnswer());
            cmd.Parameters.AddWithValue("@NbrVotes", newAnswer.getNbrVotesByAnswer());
            cmd.Parameters.AddWithValue("@NumStrawPoll", ID);

            newDataBaseTask.setMySqlCommand(cmd);
            newDataBaseTask.ExecuteNonQuery();
            newDataBaseTask.CloseConnection();
        }
        /// <summary>
        /// Disable a specific strawpoll's vote page using its <paramref name="GuidStrawPoll"/>
        /// and redirect to the welcome page
        /// </summary>
        /// <param name="GuidStrawPoll">The Globally Unique Identifier of the strawpoll</param>
        /// <returns>View Index.cshtml</returns>
        public ActionResult DeletionPage(Guid GuidStrawPoll)
        {
            String          queryDisableStrawPoll;
            ConnectionQuery newDataBaseTask = new ConnectionQuery();

            queryDisableStrawPoll = "UPDATE StrawPoll " +
                                    "SET IsActive = @IsActive " +
                                    "WHERE Guid = @GUID";

            newDataBaseTask.OpenConnection();

            SqlCommand cmd = new SqlCommand(queryDisableStrawPoll, newDataBaseTask.getSqlConnection());

            cmd.Parameters.AddWithValue("@IsActive", false);
            cmd.Parameters.AddWithValue("@GUID", GuidStrawPoll);

            newDataBaseTask.setMySqlCommand(cmd);
            newDataBaseTask.ExecuteNonQuery();
            newDataBaseTask.CloseConnection();

            return(View("Index"));
        }
        /// <summary>
        /// Increment the number of votes of the strawpoll and the answers chosen.
        /// Display the result page then (multiple answers only).
        /// </summary>
        /// <param name="ID">The ID of the strawpoll</param>
        /// <param name="checkbox">A list of String holding the label of each chosen answer</param>
        /// <returns>View Result.cshtml</returns>
        public ActionResult VoteCheckBoxes(int ID, List <String> checkbox)
        {
            //Increment database
            String          queryIncrementNbrVotes;
            ConnectionQuery newDataBaseTask = new ConnectionQuery();

            queryIncrementNbrVotes = "UPDATE StrawPoll " +
                                     "SET NbrVotes = NbrVotes + 1 " +
                                     "WHERE NumStrawPoll=@ID; " +
                                     "UPDATE Answer " +
                                     "SET NbrVotes = NbrVotes + 1 " +
                                     "WHERE NumStrawPoll = @IDAnswer AND Answer = @LabelAnswer;";

            newDataBaseTask.OpenConnection();

            foreach (String answerChosen in checkbox)
            {
                SqlCommand newcmd = new SqlCommand(queryIncrementNbrVotes, newDataBaseTask.getSqlConnection());

                newcmd.Parameters.AddWithValue("@ID", ID);
                newcmd.Parameters.AddWithValue("@IDAnswer", ID);
                newcmd.Parameters.AddWithValue("@LabelAnswer", answerChosen);

                newDataBaseTask.setMySqlCommand(newcmd);
                newDataBaseTask.ExecuteNonQuery();
            }

            newDataBaseTask.CloseConnection();

            createCookies(ID);

            //RETURN RESULT
            Models.StrawPoll myStrawPoll   = new Models.StrawPoll();
            Models.Answer    myAnswerOne   = new Models.Answer();
            Models.Answer    myAnswerTwo   = new Models.Answer();
            Models.Answer    myAnswerThree = new Models.Answer();
            Models.Answer    myAnswerFour  = new Models.Answer();

            //Get strawpoll in database
            String queryGetStrawPoll = "SELECT * FROM StrawPoll WHERE NumStrawPoll = @ID;";

            newDataBaseTask.OpenConnection();

            SqlCommand cmd = new SqlCommand(queryGetStrawPoll, newDataBaseTask.getSqlConnection());

            cmd.Parameters.AddWithValue("@ID", ID);

            SqlDataReader newReader = cmd.ExecuteReader();

            while (newReader.Read())
            {
                myStrawPoll.setStrawPollQuestion((String)newReader["Question"]);
                myStrawPoll.setMultipleChoices((bool)newReader["MultipleChoices"]);
                myStrawPoll.setNbrVotesStrawPoll((int)newReader["NbrVotes"]);
                myStrawPoll.setURLStrawPoll((String)newReader["URLStrawPoll"]);
                myStrawPoll.setURLDeletion((String)newReader["URLDeletion"]);
                myStrawPoll.setURLResults((String)newReader["URLResult"]);
                myStrawPoll.setIsActive((bool)newReader["IsActive"]);
            }

            newReader.Close();

            String queryGetAnswers = "SELECT * FROM Answer WHERE NumStrawPoll = @ID;";

            SqlCommand cmdAnswer = new SqlCommand(queryGetAnswers, newDataBaseTask.getSqlConnection());

            cmdAnswer.Parameters.AddWithValue("@ID", ID);

            SqlDataReader newReaderAnswer = cmdAnswer.ExecuteReader();

            List <Models.Answer> answers = new List <Models.Answer>();

            while (newReaderAnswer.HasRows)
            {
                while (newReaderAnswer.Read())
                {
                    Models.Answer newAnswer = new Models.Answer((String)newReaderAnswer["Answer"], (int)newReaderAnswer["NbrVotes"]);
                    answers.Add(newAnswer);
                }
                newReaderAnswer.NextResult();
            }

            newReaderAnswer.Close();
            newDataBaseTask.CloseConnection();

            //Set answers with database datas
            myAnswerOne   = answers.ElementAt(0);
            myAnswerTwo   = answers.ElementAt(1);
            myAnswerThree = answers.ElementAt(2);
            myAnswerFour  = answers.ElementAt(3);

            //SEND TO THE VIEW
            ViewBag.StrawPoll = myStrawPoll;

            ViewBag.aOne   = myAnswerOne.getAnswer();
            ViewBag.vOne   = myAnswerOne.getNbrVotesByAnswer();
            ViewBag.aTwo   = myAnswerTwo.getAnswer();
            ViewBag.vTwo   = myAnswerTwo.getNbrVotesByAnswer();
            ViewBag.aThree = myAnswerThree.getAnswer();
            ViewBag.vThree = myAnswerThree.getNbrVotesByAnswer();
            ViewBag.aFour  = myAnswerFour.getAnswer();
            ViewBag.vFour  = myAnswerFour.getNbrVotesByAnswer();

            return(View("Result"));
        }