public RentMovieLongViewModel(MovieReviewsNotes ratings, ViewMovieCarrier movie) { Movie = movie; RatingsPackage = ratings; NumberOfReviews = RatingsPackage.RatingsList.Count(); try { UserRatingsAverage = Math.Truncate(RatingsPackage.RatingsList.Average()*100)/100; } catch { UserRatingsAverage = 0; } }
public MovieReviewsNotes GetMovieRatingByID(int movieID) { using (SqlConnection cn = new SqlConnection(Settings.ConnectionString)) { var ratingsPackage = new MovieReviewsNotes(); var p = new DynamicParameters(); p.Add("MovieID", movieID); var notesList = cn.Query<MovieRating>("GetUserNotesByMovieID", p, commandType: CommandType.StoredProcedure).ToList(); ratingsPackage.NotesList = notesList; ratingsPackage.RatingsList = cn.Query<int>("GetMovieRatingList", p, commandType: CommandType.StoredProcedure).ToList(); return ratingsPackage; } }