예제 #1
0
        public async Task <ActionResult> Edit([Bind(Include = "ID,Name,Capacity,Price,Description,CategoryID")] Room room)
        {
            if (ModelState.IsValid)
            {
                db.Entry(room).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.CategoryID = new SelectList(db.Categories, "ID", "Name", room.CategoryID);
            return(View(room));
        }
예제 #2
0
        public ActionResult Edit([Bind(Include = "id,Capacity,Name,Price,Description,CreatedAt,UserID,CategoryID")] Room room)
        {
            var old = db.Rooms.Find(room.id);

            room.CreatedAt      = old.CreatedAt;
            db.Entry(old).State = EntityState.Detached;


            if (ModelState.IsValid)
            {
                db.Entry(room).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.UserID     = new SelectList(db.Users, "id", "Lastname", room.UserID);
            ViewBag.CategoryID = new SelectList(db.Categories, "ID", "Name", room.CategoryID);
            return(View(room));
        }
 public ActionResult Edit([Bind(Include = "id,Name")] Categorie categorie)
 {
     if (ModelState.IsValid)
     {
         db.Entry(categorie).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(categorie));
 }
예제 #4
0
        public ActionResult Edit([Bind(Include = "ID,Name,Capacity,Price,Description,UserID,CategoryID")] Room room)
        {
            var old = db.Rooms.Find(room.ID);

            room.CreatedAt      = old.CreatedAt;
            db.Entry(old).State = EntityState.Detached;

            if (ModelState.IsValid)
            {
                db.Entry(room).State = EntityState.Modified;
                db.SaveChanges();
                this.DisplaySuccessMessage("La room a bien été modifier");
                return(RedirectToAction("Index"));
            }
            ViewBag.UserID     = new SelectList(db.Users, "ID", "LastName", room.UserID);
            ViewBag.CategoryID = new SelectList(db.Categories, "ID", "Name", room.CategoryID);

            // ViewBag.Files = new SelectList(db.RoomFiles, "ID", "Name", room.CategoryID);
            return(View(room));
        }
예제 #5
0
        public ActionResult Edit([Bind(Include = "ID,Name")] Categorie categorie)
        {
            if (ModelState.IsValid)
            {
                db.Entry(categorie).State = EntityState.Modified;
                db.SaveChanges();
                TempData["Message"] = $"Catégorie  {categorie.Name}  enregistrée.";

                return(RedirectToAction("Index"));
            }
            return(View(categorie));
        }