コード例 #1
0
ファイル: RoomController.cs プロジェクト: nicknaam/asat
        public ActionResult Create(Room room)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Rooms.Add(room);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }

                ViewBag.RoomTypeID = new SelectList(db.RoomTypes, "RoomTypeID", "RoomTypeName", room.RoomTypeID);
                ViewBag.DataCenterID = new SelectList(db.DataCenters, "DataCenterID", "DataCenterName", room.DataCenterID);
                return View(room);
            }
            catch (Exception ex)
            {

                throw new ApplicationException("Something wrong happened Data Cant be added :", ex);
            }
        }
コード例 #2
0
ファイル: RoomController.cs プロジェクト: nicknaam/asat
        public ActionResult Edit(Room room)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(room).State = EntityState.Modified;
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
                ViewBag.RoomTypeID = new SelectList(db.RoomTypes, "RoomTypeID", "RoomTypeName", room.RoomTypeID);
                ViewBag.DataCenterID = new SelectList(db.DataCenters, "DataCenterID", "DataCenterName", room.DataCenterID);
                return View(room);
            }
            catch (Exception ex)
            {

                throw new ApplicationException("Something wrong While Editing :", ex);
            }
        }