public ActionResult Create(Hotel hotel) { if (ModelState.IsValid) { db.Hotels.AddObject(hotel); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.hotel_type_id = new SelectList(db.HotelTypes, "id", "name", hotel.hotel_type_id); ViewBag.resort_id = new SelectList(db.Resorts, "id", "name", hotel.resort_id); return View(hotel); }
/// <summary> /// Deprecated Method for adding a new object to the Hotels EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToHotels(Hotel hotel) { base.AddObject("Hotels", hotel); }
/// <summary> /// Create a new Hotel object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="resort_id">Initial value of the resort_id property.</param> /// <param name="hotel_type_id">Initial value of the hotel_type_id property.</param> /// <param name="name">Initial value of the name property.</param> public static Hotel CreateHotel(global::System.Int32 id, global::System.Int32 resort_id, global::System.Int32 hotel_type_id, global::System.String name) { Hotel hotel = new Hotel(); hotel.id = id; hotel.resort_id = resort_id; hotel.hotel_type_id = hotel_type_id; hotel.name = name; return hotel; }
public ActionResult Edit(Hotel hotel) { if (ModelState.IsValid) { db.Hotels.Attach(hotel); db.ObjectStateManager.ChangeObjectState(hotel, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.hotel_type_id = new SelectList(db.HotelTypes, "id", "name", hotel.hotel_type_id); ViewBag.resort_id = new SelectList(db.Resorts, "id", "name", hotel.resort_id); return View(hotel); }