public Review(Restaurant restaurant, User user, string reviewText, int rating, DateTime date) { // reviewID would be incremented in the database this.restaurant = restaurant; this.user = user; this.reviewText = reviewText; this.rating = rating; this.date = date; this.disposed = false; }
// Return all Reviews for a given User public List<Review> GetReviewsByUser(User user) { List<Review> matchedReviews = new List<Review>(); foreach (Review rev in reviews) { if (user.userID == rev.user.userID) { matchedReviews.Add(rev); } } return matchedReviews; }
// Add a new User to the database public string AddUser(string userName, string password, string email) { string response = ""; if (!userExists(userName)) { User user = new User(userName, password, email); users.Add(user); response = "Account created successfully."; } else { response = "An account with that username already exists in our database."; } return response; }
// Post a review for a restaurant public void PostReview(Restaurant restaurant, User user, string reviewText, int rating) { Review review = new Review(restaurant, user, reviewText, rating, DateTime.Now); reviews.Add(review); }