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 Travels EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTravels(Travel travel) { base.AddObject("Travels", travel); }
/// <summary> /// Create a new Travel object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="travel_type_id">Initial value of the travel_type_id property.</param> /// <param name="departure">Initial value of the departure property.</param> /// <param name="arrival">Initial value of the arrival property.</param> public static Travel CreateTravel(global::System.Guid id, global::System.Int32 travel_type_id, global::System.DateTime departure, global::System.DateTime arrival) { Travel travel = new Travel(); travel.id = id; travel.travel_type_id = travel_type_id; travel.departure = departure; travel.arrival = arrival; return travel; }
public void Add(Travel travel) { ctx.Travels.AddObject(travel); }