public Destination GetPreviousDestination()
        {
            var         destinations = RoadTrip.Find(GetRoadTripId()).GetDestinations();
            Destination output       = null;

            foreach (var d in destinations)
            {
                if (d.GetStop() == GetStop() - 1)
                {
                    output = d;
                }
            }
            return(output);
        }
        public override bool Equals(System.Object otherTrip)
        {
            if (!(otherTrip is RoadTrip))
            {
                return(false);
            }
            else
            {
                RoadTrip newTrip             = (RoadTrip)otherTrip;
                bool     IdEquality          = this.GetId() == newTrip.GetId();
                bool     NameEquality        = this.GetName() == newTrip.GetName();
                bool     DescriptionEquality = this.GetDescription() == newTrip.GetDescription();

                return(IdEquality && NameEquality && DescriptionEquality);
            }
        }
        public static List <RoadTrip> GetAll()
        {
            List <RoadTrip> allTrips = new List <RoadTrip> {
            };

            SqlConnection conn = DB.Connection();
            SqlDataReader rdr  = null;

            conn.Open();

            SqlCommand cmd = new SqlCommand("SELECT * FROM roadtrips;", conn);

            rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                int    id          = rdr.GetInt32(0);
                string name        = rdr.GetString(1);
                string description = rdr.GetString(2);

                RoadTrip newTrip = new RoadTrip(name, description, id);
                if (newTrip.GetDestinations().Count > 0)
                {
                    allTrips.Add(newTrip);
                }
            }

            if (rdr != null)
            {
                rdr.Close();
            }
            if (conn != null)
            {
                conn.Close();
            }

            return(allTrips);
        }
        public static RoadTrip Find(int id)
        {
            SqlConnection conn = DB.Connection();
            SqlDataReader rdr  = null;

            conn.Open();

            SqlCommand   cmd = new SqlCommand("SELECT * FROM roadtrips WHERE id = @RoadTripId;", conn);
            SqlParameter roadTripIdParameter = new SqlParameter();

            roadTripIdParameter.ParameterName = "@RoadTripId";
            roadTripIdParameter.Value         = id;
            cmd.Parameters.Add(roadTripIdParameter);
            rdr = cmd.ExecuteReader();

            int    foundRoadTripId          = 0;
            string foundRoadTripName        = null;
            string foundRoadTripDescription = null;

            while (rdr.Read())
            {
                foundRoadTripId          = rdr.GetInt32(0);
                foundRoadTripName        = rdr.GetString(1);
                foundRoadTripDescription = rdr.GetString(2);
            }
            RoadTrip foundRoadTrip = new RoadTrip(foundRoadTripName, foundRoadTripDescription, foundRoadTripId);

            if (rdr != null)
            {
                rdr.Close();
            }
            if (conn != null)
            {
                conn.Close();
            }
            return(foundRoadTrip);
        }
        public int CountStops()
        {
            List <Destination> tripDestinations = RoadTrip.Find(this.GetRoadTripId()).GetDestinations();

            return(tripDestinations.Count);
        }