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