public void AddReview(RatingAndReview review) { String sql = "INSERT INTO Reviews (rating, review, book_id) VALUES ('" + review.Rating.ToString() + "','" + review.Review + "','" + review.BookId.ToString() + "')"; DbUtils.ExecuteNonQuery(_connection, sql); }
public RatingAndReview SelectReviewById(int id) { RatingAndReview review = null; String sql = "SELECT * FROM Reviews WHERE review_id = '" + id + "'"; SqlCommand command = new SqlCommand(sql, _connection); try { _connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { review = new RatingAndReview(Int32.Parse(reader["review_id"].ToString()), Int32.Parse(reader["rating"].ToString()), reader["review"].ToString(), Guid.Parse(reader["book_id]"].ToString())); } } } catch (System.Exception ex) { Console.WriteLine(ex); } finally { if (_connection.State == ConnectionState.Open) { _connection.Close(); } } return(review); }
public void UpdateReview(int id, RatingAndReview review) { String sql = "UPDATE Reviews SET Rating ='" + review.Rating + "' , Review = '" + review.Review + "' WHERE review_id ='" + id.ToString() + "'"; DbUtils.ExecuteNonQuery(_connection, sql); }
internal void Persist(RepositoryFactory repositoryFactory) { RatingAndReview ratingAndReview = new RatingAndReview { BookId = this.BookId, Rating = this.Rating, Review = this.Review }; repositoryFactory.GetRatingAndReviewRepository() .Save(ratingAndReview); }
public void UpdateReview(int id, ReviewRequest reviewRequest) { RatingAndReview review = new RatingAndReview(id, reviewRequest.Rating, reviewRequest.Review, reviewRequest.BookId); reviewRepo.UpdateReview(id, review); }
public void SaveReview(ReviewRequest reviewRequest) { RatingAndReview review = new RatingAndReview(reviewRequest.Rating, reviewRequest.Review, reviewRequest.BookId); reviewRepo.AddReview(review); }
public ReviewResponse GetReviewById(int id) { RatingAndReview review = reviewRepo.SelectReviewById(id); return(new ReviewResponse(review.Id, review.Rating, review.Review, review.BookId)); }
public RatingAndReviewListItemViewModel(RatingAndReview ratingAndReview) { this.Id = ratingAndReview.Id; this.Rating = ratingAndReview.Rating; this.Review = ratingAndReview.Review; }