public void Update(string review, int stars) { int targetId = this.GetId(); SqlConnection conn = DB.Connection(); conn.Open(); SqlCommand cmd = new SqlCommand("UPDATE reviews SET review = @Review, stars = @Stars WHERE id = @TargetId", conn); cmd.Parameters.Add(new SqlParameter("@Review", review)); cmd.Parameters.Add(new SqlParameter("@Stars", stars)); cmd.Parameters.Add(new SqlParameter("@TargetId", targetId)); cmd.ExecuteNonQuery(); Review updatedReview = Find(targetId); this._review = updatedReview.GetReview(); this._stars = updatedReview.GetStars(); if (conn != null) { conn.Close(); } }
public override bool Equals(System.Object otherReview) { if (!(otherReview is Review)) { return(false); } else { Review newReview = (Review)otherReview;; bool idEquality = this.GetId() == newReview.GetId(); bool reviewEquality = this.GetReview() == newReview.GetReview(); bool starsEquality = this.GetStars() == newReview.GetStars(); bool restaurantIdEquality = this.GetRestaurantId() == newReview.GetRestaurantId(); return(idEquality && reviewEquality && starsEquality && restaurantIdEquality); } }