public ActionResult Cloture(int id, Form form)
        {
            if (ModelState.IsValid)
            {
                using (context)
                {
                    Form _form = context.Forms.Single(p => p.FormId == id);

                    _form.Closed = "yes";

                    context.Entry(_form).State = EntityState.Modified;
                    context.SaveChanges();

                    return RedirectToAction("Index");
                }

            }
            return View(form);
        }
 //Renvoie vers la page pour afficher le lien pour accéder au formulaire
 public ActionResult ShowPath(Form form)
 {
     return View(form);
 }
        public ActionResult Delete(int id, Form form)
        {
            //Get form to delete
            Form _form = context.Forms.Single(p => p.FormId == id);

            #region DeleteAnswers
            //Select all asnwers to this form
            List<Answer> answersToDelete = context.Answers.Where(i => i.question.form.FormId == id).ToList();

            //On supprime les réponses de la base
            foreach (Answer answerToDelete in answersToDelete)
            {
                context.Answers.Remove(answerToDelete);
            }
            #endregion

            #region DeleteQuestions

            //Select All questions to this form
            List<Question> questionsToDelete = context.Questions.Where(i => i.FormId == id).ToList();

            //On supprime chaque question
            foreach (Question questionToDelete in questionsToDelete)
            {
                context.Questions.Remove(questionToDelete);
            }

            #endregion

            #region DeleteStats

            //Select All stats to this form
            List<Stat> statsToDelete = context.Stats.Where(i => i.FormId == id).ToList();

            //On supprime chaque stat
            foreach(Stat statToDelete in statsToDelete)
            {
                context.Stats.Remove(statToDelete);
            }

            #endregion

            //Delete form
            context.Forms.Remove(_form);

            context.SaveChanges();
            return RedirectToAction("Index");
        }
        public ActionResult Edit(int id, Form form)
        {
            if (ModelState.IsValid)
            {
                using (context)
                {
                    Form _form = context.Forms.Single(p => p.FormId == id);

                    _form.Title = form.Title;
                    _form.Description = form.Description;

                    context.Entry(_form).State = EntityState.Modified;
                    context.SaveChanges();

                    return RedirectToAction("Index");
                }

            }
            return View(form);
        }
        public ActionResult Create(Form form)
        {
            if (ModelState.IsValid)
            {
                //On génère le le hash
                Random alea = new Random();

                //On génère l'url
                string url = "Response/GoToForm/";

                form.Hash = alea.Next(1000000000).ToString();
                form.Url = url + form.Hash;

                //Le formulaire n'est pas cloturé puisqu'il vient d'etre créer
                form.Closed = null;

                context.Forms.Add(form);
                context.SaveChanges();
                return RedirectToAction("ShowPath",form);
            }

            return View(form);
        }