public ActionResult Edit([Bind(Include = "Id,Libelle")] TypedeFormations typedeFormations)
 {
     if (ModelState.IsValid)
     {
         db.Entry(typedeFormations).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(typedeFormations));
 }
        public ActionResult Create([Bind(Include = "Id,Libelle")] TypedeFormations typedeFormations)
        {
            if (ModelState.IsValid)
            {
                db.TypedeFormations.Add(typedeFormations);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(typedeFormations));
        }
        public ActionResult AddSimpleFormation(decimal id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TypedeFormations type = db.TypedeFormations.Find(id);

            ViewBag.Libelle = type.Libelle;

            Formations formation = initializeFormation(id);

            return(View(formation));
        }
        public ActionResult Edit(decimal id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TypedeFormations typedeFormations = db.TypedeFormations.Find(id);

            if (typedeFormations == null)
            {
                return(HttpNotFound());
            }
            return(View(typedeFormations));
        }
        public ActionResult AddSimpleFormation(Formations formation)
        {
            if (ModelState.IsValidField("DateDebut") && ModelState.IsValidField("DateFin") && ModelState.IsValidField("DateLimiteInscription") && ModelState.IsValidField("DateTestSelection") &&
                ModelState.IsValidField("NombreTotalHeures") && ModelState.IsValidField("NbreHeureCentre") && ModelState.IsValidField("NbrHeureStructAccueil") &&
                ModelState.IsValidField("TotalHeureFOAD") && ModelState.IsValidField("HeureELearning") && ModelState.IsValidField("TotalAutresHeures") &&
                ModelState.IsValidField("TypeHeureContenu") && ModelState.IsValidField("CoutComplet") && ModelState.IsValidField("NbreHeureAutreEspace") &&
                ModelState.IsValidField("Personnel.Nom") && ModelState.IsValidField("Personnel.Prenom") && ModelState.IsValidField("Personnel.Email") && ModelState.IsValidField("Personnel.Telephone") &&
                ModelState.IsValidField("Lieux.Ville") && ModelState.IsValidField("Lieux.Adresse") && ModelState.IsValidField("Lieux.CodePostal") &&
                ModelState.IsValidField("Habilitations.NumeroHabilitation") && ModelState.IsValidField("Habilitations.DebutDateDelivrance") && ModelState.IsValidField("Habilitations.FinDateDelivrance") && ModelState.IsValidField("Habilitations.NumeroSession") && ModelState.IsValidField("Habilitations.DateEPMSP") && ModelState.IsValidField("Habilitations.DateTEP")
                )
            {
                // Mise en place de l'organisateur pédagogique
                Personnel p = new Personnel();
                p.Nom       = formation.Personnel.Nom;
                p.Prenom    = formation.Personnel.Prenom;
                p.Email     = formation.Personnel.Email;
                p.Telephone = formation.Personnel.Telephone;

                Lieux l = new Lieux();
                l.Email      = formation.Lieux?.Email;
                l.Adresse    = formation.Lieux.Adresse;
                l.CodePostal = formation.Lieux.CodePostal;
                l.Ville      = formation.Lieux.Ville;
                l.Telephone  = formation.Lieux.Telephone;

                formation.LieuSiNonPorteuse  = l.Id;
                formation.IdOrganisateurpeda = formation.Personnel.Id;
                formation.FormationEnded     = false;

                db.Lieux.Add(l);
                db.Personnel.Add(p);
                db.Formations.Add(formation);
                if (formation.Habilitations != null)
                {
                    db.Habilitations.Add(formation.Habilitations);
                }
                try { db.SaveChanges(); }
                catch (Exception e)
                {
                }


                return(backToGoodFormation((decimal)formation.OrganismeId, (decimal)formation.TypedeFormationsId));
            }
            TypedeFormations type = db.TypedeFormations.Find(formation.TypedeFormationsId);

            ViewBag.Libelle = type.Libelle;
            return(View(formation));
        }