예제 #1
0
        public ActionResult Create(RoomOccupationBed roomoccupationbed)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.RoomOccupationBed.AddObject(roomoccupationbed);
                    db.SaveChanges();
                    return RedirectToAction("Index", new { Id = roomoccupationbed.IdRoom });
                }
            }
            catch (Exception)
            {
                ViewBag.Room = db.Room.SingleOrDefault(model => model.Id.Equals(roomoccupationbed.IdRoom));
                ViewBag.IdRoom = roomoccupationbed.IdRoom;
                ViewBag.IdRoomBed = new SelectList(db.RoomBed, "Id", "Name", roomoccupationbed.IdRoomBed);
                ViewBag.Error = "Ya existe esa asignación de cama.";
                return View(roomoccupationbed);
            }

            ViewBag.Room = db.Room.SingleOrDefault(model => model.Id.Equals(roomoccupationbed.IdRoom));
            ViewBag.IdRoom = roomoccupationbed.IdRoom;
            ViewBag.IdRoomBed = new SelectList(db.RoomBed, "Id", "Name", roomoccupationbed.IdRoomBed);
            return View(roomoccupationbed);
        }
예제 #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the RoomOccupationBed EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRoomOccupationBed(RoomOccupationBed roomOccupationBed)
 {
     base.AddObject("RoomOccupationBed", roomOccupationBed);
 }
예제 #3
0
 public ActionResult Edit(RoomOccupationBed roomoccupationbed)
 {
     if (ModelState.IsValid)
     {
         db.RoomOccupationBed.Attach(roomoccupationbed);
         db.ObjectStateManager.ChangeObjectState(roomoccupationbed, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index", new { Id = roomoccupationbed.IdRoom });
     }
     ViewBag.IdRoom = roomoccupationbed.IdRoom;
     ViewBag.IdRoomBed = new SelectList(db.RoomBed, "Id", "Name", roomoccupationbed.IdRoomBed);
     return View(roomoccupationbed);
 }
예제 #4
0
 /// <summary>
 /// Create a new RoomOccupationBed object.
 /// </summary>
 /// <param name="idRoom">Initial value of the IdRoom property.</param>
 /// <param name="idRoomBed">Initial value of the IdRoomBed property.</param>
 /// <param name="quantity">Initial value of the Quantity property.</param>
 public static RoomOccupationBed CreateRoomOccupationBed(global::System.Int32 idRoom, global::System.Int32 idRoomBed, global::System.Int32 quantity)
 {
     RoomOccupationBed roomOccupationBed = new RoomOccupationBed();
     roomOccupationBed.IdRoom = idRoom;
     roomOccupationBed.IdRoomBed = idRoomBed;
     roomOccupationBed.Quantity = quantity;
     return roomOccupationBed;
 }