public ActionResult Edit(Booking booking) { if (ModelState.IsValid) { db.Bookings.Attach(booking); db.ObjectStateManager.ChangeObjectState(booking, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.hotel_id = new SelectList(db.Hotels, "id", "name", booking.hotel_id); return View(booking); }
public ActionResult AddHotelToCart(int hotel_id) { Cart cart = new Cart(); Booking newbooking = new Booking { id = Guid.NewGuid(), Hotel = cart.ctx.Hotels.FirstOrDefault(h => h.id == hotel_id) }; //init empty travel Travel travel = new Travel { id = Guid.NewGuid() }; cart.ctx.AddToTravels(travel); newbooking.Travel = travel; newbooking.Travel.Passangers.Add(new Passanger { id = Guid.NewGuid() });//at least one passanger cart.ctx.Bookings.AddObject(newbooking); return PartialView("_CartPartial", cart); }
/// <summary> /// Deprecated Method for adding a new object to the Bookings EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToBookings(Booking booking) { base.AddObject("Bookings", booking); }
/// <summary> /// Create a new Booking object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="customer_id">Initial value of the customer_id property.</param> /// <param name="travel_id">Initial value of the travel_id property.</param> /// <param name="hotel_id">Initial value of the hotel_id property.</param> /// <param name="start_date">Initial value of the start_date property.</param> /// <param name="duration">Initial value of the duration property.</param> /// <param name="single_rooms">Initial value of the single_rooms property.</param> /// <param name="double_rooms">Initial value of the double_rooms property.</param> public static Booking CreateBooking(global::System.Guid id, global::System.Guid customer_id, global::System.Guid travel_id, global::System.Int32 hotel_id, global::System.DateTime start_date, global::System.Int32 duration, global::System.Int32 single_rooms, global::System.Int32 double_rooms) { Booking booking = new Booking(); booking.id = id; booking.customer_id = customer_id; booking.travel_id = travel_id; booking.hotel_id = hotel_id; booking.start_date = start_date; booking.duration = duration; booking.single_rooms = single_rooms; booking.double_rooms = double_rooms; return booking; }