public void RegisterTravel(string company, string startCity, DateTime startTime, string stop, string endCity, DateTime endTime, int ticketPrice) { using (var db = new TransportSystemDB()) { Travel travel = new Travel() { Company = company, StartCity = startCity , StartTime = startTime, EndCity = endCity, EndTime = endTime, TicketPrice = ticketPrice }; Stop intermediaryStop = new Stop() { stop1 = stop, id = travel.id }; db.Stops.AddObject(intermediaryStop); db.Travels.AddObject(travel); db.SaveChanges(); } }
/// <summary> /// Create a new Travel object. /// </summary> /// <param name="company">Initial value of the Company property.</param> /// <param name="startCity">Initial value of the StartCity property.</param> /// <param name="startTime">Initial value of the StartTime property.</param> /// <param name="endCity">Initial value of the EndCity property.</param> /// <param name="endTime">Initial value of the EndTime property.</param> /// <param name="ticketPrice">Initial value of the TicketPrice property.</param> /// <param name="id">Initial value of the id property.</param> public static Travel CreateTravel(global::System.String company, global::System.String startCity, global::System.DateTime startTime, global::System.String endCity, global::System.DateTime endTime, global::System.Int32 ticketPrice, global::System.Int32 id) { Travel travel = new Travel(); travel.Company = company; travel.StartCity = startCity; travel.StartTime = startTime; travel.EndCity = endCity; travel.EndTime = endTime; travel.TicketPrice = ticketPrice; travel.id = id; return travel; }
/// <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); }