Example #1
0
        public ActionResult Create(Cours cours)
        {
            cours.Matiere = this.matiereRepository.Get(cours.Matiere.Id);
            cours.TypeCours = db.TypesCours.Find(cours.TypeCours.Id);

               foreach (ModelState modelState in ViewData.ModelState.Values)
            {

                foreach (ModelError error in modelState.Errors)
                {
                    System.Diagnostics.Debug.WriteLine(error.ErrorMessage);
                }
            }

            if (ModelState.IsValid)
               {

                    this.coursRepository.Insert(cours);
                    this.coursRepository.Save();
                    return RedirectToAction("Index");

            }

            return View(cours);
        }
Example #2
0
 public void Insert(Cours cours)
 {
     this.context.Cours.Add(cours);
 }
Example #3
0
 public void Edit(Cours cours)
 {
     this.context.Entry(cours).State = System.Data.EntityState.Modified;
 }
Example #4
0
 public void Delete(Cours cours)
 {
     this.context.Cours.Remove(cours);
 }
Example #5
0
 public ActionResult Edit(Cours cours)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cours).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(cours);
 }