public ActionResult CreateSalle(Salle salle)
        {
            System.Diagnostics.Debug.WriteLine("test");
            salle.Batiment = this.batimentRepository.Get(salle.Batiment.Id);
            //System.Diagnostics.Debug.WriteLine("test : %d",salle.Batiment.Id);
            foreach (ModelState modelState in ViewData.ModelState.Values)
            {
                foreach (ModelError error in modelState.Errors)
                {
                    System.Diagnostics.Debug.WriteLine(error.ErrorMessage);
                }
            }
            if (ModelState.IsValid)
            {
                if (salle.Capacite <= 0)
                {
                    System.Diagnostics.Debug.WriteLine("La capacit&eacute; de la salle est incorrecte.");
                }
                else
                {
                    this.salleRepository.Insert(salle);
                    this.salleRepository.Save();
                    return RedirectToAction("IndexSalle");
                }
            }

            return View(salle);
        }
        public ActionResult EditSalle(Salle salle)
        {
            Salle s = this.salleRepository.GetEager(salle.Id);
            s.Batiment = this.batimentRepository.Get(salle.Batiment.Id);
            s.Libelle = salle.Libelle;
            s.Capacite = salle.Capacite;
            s.APrises = salle.APrises;
            s.AProjecteur = salle.AProjecteur;

            if (ModelState.IsValid)
            {

                this.salleRepository.Entry(s);
                this.salleRepository.Save();

                return RedirectToAction("IndexSalle");
            }
            return View(s);
        }
Example #3
0
 public void Entry(Salle e)
 {
     this.context.Entry(e).State = System.Data.EntityState.Modified;
 }