示例#1
0
        public ActionResult Create(Room room)
        {
            if (ModelState.IsValid)
            {
                db.Rooms.Add(room);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.BuildingID = new SelectList(db.Buildings, "ID", "BuildingName", room.BuildingID);
            return View(room);
        }
示例#2
0
 public ActionResult Edit(Room room)
 {
     if (ModelState.IsValid)
     {
         db.Entry(room).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.BuildingID = new SelectList(db.Buildings, "ID", "BuildingName", room.BuildingID);
     return View(room);
 }