public ActionResult Create(FormCollection collection)
        {
            try
            {

                AjoutFormationSvc controller = new AjoutFormationSvc();
                SessionContainer scc = new SessionContainer();

                CtrlAttributesEnregistrer attributes = new CtrlAttributesEnregistrer();
                attributes.param_f_formation1_diplome = collection["Diplome"];
                attributes.param_f_formation1_lieu = collection["Lieu"];
                attributes.param_f_niveau_formation = int.Parse(collection["Niveau"]);

                controller.DoEnregistrer(scc, attributes);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
 public void DoEnregistrer(SessionContainer scc, ControllerBaseAttributes attributes)
 {
     CtrlAttributesEnregistrer attEnregistrer = (CtrlAttributesEnregistrer) attributes;
     attributes.enableRedirectParam = true;
     Internaute internaute = scc.Internaute;
     CV cv = new CV();
     // On r�cup�re le Pourcentage d'origine
     CVFactory cvFactory = new CVFactory();
     cv = cvFactory.GetTableauBord(internaute.IntId);
     // On cr� un nouveau pour la mise � jour
     cv = new CV();
     cv.IntId = internaute.IntId;
     // poucentage pour ajout
     Formation formation1 = new Formation();
     formation1.intId=internaute.IntId;
     int param_renseign = 0;
     /* Formation 1 */
     if (HasStartingMonthAndYear(attEnregistrer)) {
         param_renseign = FormatAndSetFormationDate(attEnregistrer, formation1, param_renseign);
     }
     if (attEnregistrer.param_f_formation1_date_fin_mois != null
         && attEnregistrer.param_f_formation1_date_fin_annee != null)
     {
             DateTime date = new DateTime(attEnregistrer.param_f_formation1_date_fin_annee.Value, attEnregistrer.param_f_formation1_date_fin_mois.Value, 1);
             formation1.frmDateFin = date;
             param_renseign++;
         }
     if (attEnregistrer.param_f_formation1_etablissement != null) {
         formation1.frmEcole = attEnregistrer.param_f_formation1_etablissement;
         param_renseign++;
     }
     if (attEnregistrer.param_f_formation1_lieu != null) {
         formation1.frmLieu=attEnregistrer.param_f_formation1_lieu;
         param_renseign++;
     }
     if (attEnregistrer.param_f_formation1_diplome != null) {
         formation1.frmDiplome=attEnregistrer.param_f_formation1_diplome;
         param_renseign++;
     }
     if (attEnregistrer.param_f_formation1_obtenu != null)
     {
         formation1.frmObtenu=attEnregistrer.param_f_formation1_obtenu.Value;
         param_renseign++;
     }
     if (attEnregistrer.param_f_formation1_specialisation != null) {
         formation1.frmSpecialite=attEnregistrer.param_f_formation1_specialisation;
         param_renseign++;
     }
     if (attEnregistrer.param_f_formation1_tfo_code != null)
     {
         formation1.tfoCode=attEnregistrer.param_f_formation1_tfo_code.Value;
         param_renseign++;
     }
     if (param_renseign > 0) {
         if (attEnregistrer.param_f_formation1_frmid == null
             || attEnregistrer.param_f_formation1_frmid == null)
         {
                 FormationFactory.Insert(formation1);
             }
         else {
             formation1.frmId=attEnregistrer.param_f_formation1_frmid.Value;
             FormationFactory.Update(formation1);
         }
     }
     int pourcent = FormationFactory.GetPourcent(internaute.IntId);
     if (attEnregistrer.param_f_niveau_formation != null)
     {
         cv.nivCode = (attEnregistrer.param_f_niveau_formation.Value);
         pourcent = pourcent + 5;
     }
     cv.SetCuvPourcentFormation(pourcent);
     cvFactory.InsertFormation(cv);
 }
        //
        // GET: /Formation/
        public ActionResult Index(long intId = 1)
        {
            Internaute internaute = new SessionContainer().Internaute;
            intId = internaute.IntId;
            List<Formation> results = FormationFactory.List(intId);

                    String output = "<h1>Liste des formations</h1><table class=\"table\">";
                    int pourcent = FormationFactory.GetPourcent(intId);

                    output+="<h4>Pourcentage de remplissage : "+pourcent +"</h4>";

                    output+="<tr><td>ID internaute</td><td>ID Formation</td><td> Date Début</td><td> Date Fin</td><td>Ecole"
                            +"</td><td>Lieu</td><td>Specialite</td><td>Diplome</td><td>Obtenu"
                            + "</td><td>Code</td><td>Libelle</td></tr>";
                    foreach(Formation result in results){
                        output+=result;
                    }
                    output+="</table>";
                    this.ViewData["pourcent"] = pourcent;
                    this.ViewData["rows"] = output;
                    this.ViewData["intNom"] = internaute.nom;
                    this.ViewData["intPreNom"] = internaute.prenom;
                    return View();
        }