/***************** INTERSECTION METHODS ********************/

        public bool AddIntersection(int lineId, int stationId)
        {
            //check if station exists on other lines
            var intersectQuery =
                from stn in db.line_informations
                where stn.line_id != lineId && stn.station_id == stationId
                select stn;

            //run query and store line id's where station already exists
            List <int> ids = new List <int>();

            foreach (var stn in intersectQuery)
            {
                ids.Add(stn.line_id);
            }

            //if the station exists on another line
            if (ids.Count > 0)
            {
                Console.WriteLine("Adding Intersections");
                //iterate through ids list and run linq query to add intersections
                for (int i = 0; i < ids.Count; i++)
                {
                    //add intersection
                    var addIntersectQuery = new intersection {
                        station_id = stationId,
                        line1_id   = lineId,
                        line2_id   = ids[i]
                    };

                    //submit the changes
                    try
                    {
                        db.intersections.InsertOnSubmit(addIntersectQuery);
                        db.SubmitChanges();
                        Console.WriteLine("Inserted intersection info Successfully");
                    }
                    catch (Exception eX)
                    {
                        Console.WriteLine("Failed to insert intersection info : " + eX);
                        return(false);
                    }
                }

                return(true);
            }

            Console.WriteLine("No intersections to add!");
            return(false);
        }
 private void detach_intersections(intersection entity)
 {
     this.SendPropertyChanging();
     entity.station = null;
 }
 partial void Deleteintersection(intersection instance);
 partial void Updateintersection(intersection instance);
 partial void Insertintersection(intersection instance);
 private void detach_intersections1(intersection entity)
 {
     this.SendPropertyChanging();
     entity.line1 = null;
 }
 private void attach_intersections(intersection entity)
 {
     this.SendPropertyChanging();
     entity.line = this;
 }