} //done public Reviews GetReviewsforAverage(string MovieName) // int reviewid, int movieid, int userid, int rating) { Reviews reviews = new Reviews(); string sql2 = string.Format(@"SELECT Reviews.ReviewID as rid, Reviews.MovieID as mid, Reviews.UserID as uid, Rating FROM Reviews INNER JOIN Movies ON Reviews.MovieID = Movies.MovieID WHERE Movies.MovieName='{0}';" , MovieName); DataSet ds = datatier.ExecuteNonScalarQuery(sql2); DataTable dt = ds.Tables["TABLE"]; if (dt.Rows.Count == 0) { return(null); } else { foreach (DataRow row in dt.Rows) { reviews.Add(new Review(Convert.ToInt32(row["rid"]), Convert.ToInt32(row["mid"]), Convert.ToInt32(row["uid"]), Convert.ToInt32(row["Rating"]))); } return(reviews); } } //done
} // done public Reviews GetReviews(int MovieID) { Reviews reviews = new Reviews(); string sql = string.Format(@"SELECT UserID, Rating FROM Reviews WHERE MovieID={0} ORDER BY Rating Desc, UserID ASC;", MovieID); DataSet ds = datatier.ExecuteNonScalarQuery(sql); DataTable dt = ds.Tables["TABLE"]; if (dt.Rows.Count == 0) { return(null); } else { foreach (DataRow row in dt.Rows) { reviews.Add(new Review(Convert.ToInt32(row["UserID"]), MovieID, Convert.ToInt32(row["Rating"]))); } return(reviews); } } //done
// // constructor: // public Movie(int movieid, string moviename, Reviews reviews) { MovieID = movieid; MovieName = moviename; MovieReviews = reviews; }