public ModifyReviewForm(Review review) { InitializeComponent(); errorLabel.Text = ""; editWindowTitle("Examine Review"); editTitle(review.movie); reviewTimeLabel.Text = "Reviewed at " + review.lastEdited.ToShortTimeString() + " on " + review.lastEdited.ToShortDateString(); if(ApplicationManager.loggedIn != null && ApplicationManager.loggedIn.username.Equals(review.author)) { authorLabel.Text = ""; authorFrontLabel.Text = ""; ratingBox.Enabled = true; contentBox.Enabled = true; deleteButton.Show(); this.user = review.author; } else { authorLabel.Text = review.author; authorFrontLabel.Text = "Author:"; ratingBox.Enabled = false; contentBox.Enabled = false; deleteButton.Hide(); user = null; } ratingBox.Text = review.rating; contentBox.Text = review.content; this.review = review; movie = null; }
public static List<FormError> createReview(string rauthor, string rmovie, string rrating, string rcontent) { List<FormError> errors = new List<FormError>(); Review review = new Review() { ID = DataAccess.generateID(), author = rauthor, movie = rmovie, rating = rrating, content = rcontent, createdAt = DateTime.Now, lastEdited = DateTime.Now}; if (review.valid(errors)) { List<Review> reviews = DataAccess.readReviews(); reviews.Add(review); DataAccess.writeReviews(reviews); } return errors; }
public ModifyReviewForm(Review review, string user) { InitializeComponent(); errorLabel.Text = ""; editWindowTitle("Edit Review"); editTitle(review.movie); authorLabel.Text = ""; authorFrontLabel.Text = ""; reviewTimeLabel.Text = "Reviewed at " + review.lastEdited.ToShortTimeString() + " on " + review.lastEdited.ToShortDateString(); ratingBox.Enabled = true; contentBox.Enabled = true; ratingBox.Text = review.rating; contentBox.Text = review.content; deleteButton.Show(); this.user = user; this.review = review; movie = null; }
public static bool saveReview(Review review, List<FormError> errors) { if (review.valid(errors, true)) { List<Review> reviews = DataAccess.readReviews(); int i = 0; while (i < reviews.Count && reviews.ElementAt(i).ID != review.ID) { i++; } if (i < reviews.Count) { reviews.ElementAt(i).rating = review.rating; reviews.ElementAt(i).content = review.content; reviews.ElementAt(i).lastEdited = DateTime.Now; DataAccess.writeReviews(reviews); return true; } } return false; }