Example #1
0
        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();
            }
        }
Example #2
0
 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);
     }
 }
Example #3
0
        public void Test_Review_Update_ChangeReviewInfo()
        {
            // Arrange
            Restaurant testRestaurant = new Restaurant("Pizza Factory", "5th Street", "530-816-9999", 0);

            testRestaurant.Save();
            Review testReview = new Review("Their pizza was marvelous", 4, testRestaurant.GetId());

            testReview.Save();
            Review testReview1 = new Review("First time was great, second time their pizza was bland", 2, testRestaurant.GetId());

            testReview1.Save();

            // Act
            testReview.Update("First time was great, second time their pizza was bland", 2);
            // testReview.SetId(testRestaurant.GetId());
            // testReview1.SetId(testRestaurant.GetId());

            // Assert
            Assert.Equal(testReview.GetReview(), testReview1.GetReview());
        }