public static LesFormations FindByID(int id)
 {
     using (BDDContext context = new BDDContext())
     {
         LesFormations f = context.Formations.FirstOrDefault(s => s.LesFormationsId == id);
         return(f);
     }
 }
 public static void Create(LesFormations formation)
 {
     try
     {
         using (BDDContext context = new BDDContext())
         {
             context.Formations.Add(formation);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
     }
 }
        public ActionResult Edit(int id, LesFormations formation, FormCollection form)
        {
            //string champ = form.GetValues("champSupplementaire").FirstOrDefault();
            //if (!string.IsNullOrWhiteSpace(champ))
            //{
            //    ViewBag.Info = "Champ renseigné : " + champ;
            //    return View();
            //}

            try
            {
                // TODO: Add update logic here
                LesFormationsDAO.Edit(formation);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public static void Edit(LesFormations formation)
        {
            try
            {
                using (BDDContext context = new BDDContext())
                {
                    LesFormations f = context.Formations.FirstOrDefault(s => s.LesFormationsId == formation.LesFormationsId);

                    f.titre           = formation.titre;
                    f.Description     = formation.Description;
                    f.LesCursus_suivi = formation.LesCursus_suivi;
                    //f.SessionFormations = formation.SessionFormations;

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
        }
        public ActionResult Create(LesFormations formation)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // TODO: Add insert logic here
                    LesFormationsDAO.Create(formation);

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(formation));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Erreur", ex);
                ViewBag.Error = "Un problème est survenu";
                return(View(formation));
            }
        }