Example #1
0
        public void AddTrail(Trail newTrail)
        {
            MySqlConnection conn = DB.Connection();

            conn.Open();
            var cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"INSERT INTO hikers_trails (hiker_id, trail_id) VALUES (@hikerId, @trailId);";
            MySqlParameter trailId = new MySqlParameter();

            trailId.ParameterName = "@trailId";
            trailId.Value         = newTrail.GetId();
            cmd.Parameters.Add(trailId);
            MySqlParameter hikerId = new MySqlParameter();

            hikerId.ParameterName = "@hikerId";
            hikerId.Value         = this._id;
            cmd.Parameters.Add(hikerId);
            cmd.ExecuteNonQuery();
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
        }
Example #2
0
 public override bool Equals(System.Object otherTrail)
 {
     if (!(otherTrail is Trail))
     {
         return(false);
     }
     else
     {
         Trail newTrail              = (Trail)otherTrail;
         bool  idEquality            = this.GetId() == newTrail.GetId();
         bool  nameEquality          = this.GetName() == newTrail.GetName();
         bool  difficultyEquality    = this.GetDifficulty() == newTrail.GetDifficulty();
         bool  waterfallsEquality    = this.GetWaterfalls() == newTrail.GetWaterfalls();
         bool  summitsEquality       = this.GetSummits() == newTrail.GetSummits();
         bool  streamsEquality       = this.GetStreams() == newTrail.GetStreams();
         bool  mountainViewsEquality = this.GetMountainViews() == newTrail.GetMountainViews();
         bool  meadowsEquality       = this.GetMeadows() == newTrail.GetMeadows();
         bool  lakesEquality         = this.GetLakes() == newTrail.GetLakes();
         bool  locationEquality      = this.GetLocation() == newTrail.GetLocation();
         return(idEquality && nameEquality && difficultyEquality && waterfallsEquality && summitsEquality && streamsEquality && mountainViewsEquality && lakesEquality && meadowsEquality && locationEquality);
     }
 }