/***************** LINE EDITOR METHODS ********************/

        public bool AddToLine(int lineId, int stationId, int position, decimal distanceToNext, decimal timeToNext)
        {
            //check station is not already on line
            var alreadyOnLineQuery =
                (from stn in db.line_informations
                 where stn.line_id == lineId && stn.station_id == stationId
                 select stn

                ).SingleOrDefault();

            //if the station is already on the line return false
            if (alreadyOnLineQuery != null)
            {
                return(false);
            }


            //create query
            var lineInfo = new line_information {
                line_id          = lineId,
                station_id       = stationId,
                position         = position,
                distance_to_next = distanceToNext,
                time_to_next     = timeToNext,
                delay_to_next    = 0
            };

            //insert values and submit changes
            try
            {
                db.line_informations.InsertOnSubmit(lineInfo);
                db.SubmitChanges();
                Console.WriteLine("Inserted line info Successfully");

                //check for and add intersections
                AddIntersection(lineId, stationId);

                return(true);
            }
            catch (Exception eX)
            {
                Console.WriteLine("Failed to insert line info : " + eX);
                return(false);
            }
        }
 private void detach_line_informations(line_information entity)
 {
     this.SendPropertyChanging();
     entity.station = null;
 }
 partial void Deleteline_information(line_information instance);
 partial void Updateline_information(line_information instance);
 partial void Insertline_information(line_information instance);
 private void attach_line_informations(line_information entity)
 {
     this.SendPropertyChanging();
     entity.line = this;
 }