Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }