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); }
public void Insert(Cours cours) { this.context.Cours.Add(cours); }
public void Edit(Cours cours) { this.context.Entry(cours).State = System.Data.EntityState.Modified; }
public void Delete(Cours cours) { this.context.Cours.Remove(cours); }
public ActionResult Edit(Cours cours) { if (ModelState.IsValid) { db.Entry(cours).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(cours); }