public ActionResult Create(Room room) { if (ModelState.IsValid) { db.Room.AddObject(room); db.SaveChanges(); return RedirectToAction("Index", new { id = room.IdHotel }); } ViewBag.Hotel = db.Hotel.SingleOrDefault(u => u.Id.Equals(room.IdHotel)); return View(room); }
/// <summary> /// Deprecated Method for adding a new object to the Room EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToRoom(Room room) { base.AddObject("Room", room); }
/// <summary> /// Create a new Room object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="description">Initial value of the Description property.</param> /// <param name="idHotel">Initial value of the IdHotel property.</param> /// <param name="active">Initial value of the Active property.</param> public static Room CreateRoom(global::System.Int32 id, global::System.String name, global::System.String description, global::System.Int32 idHotel, global::System.Boolean active) { Room room = new Room(); room.Id = id; room.Name = name; room.Description = description; room.IdHotel = idHotel; room.Active = active; return room; }
public ActionResult Edit(Room room) { if (ModelState.IsValid) { db.Room.Attach(room); db.ObjectStateManager.ChangeObjectState(room, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index", new { id = room.IdHotel }); } return View(room); }