示例#1
0
 // Methods:
 public double GetAvgReviewRating()
 {
     if (Reviews.Count == 0)
     {
         return(0);
     }
     return(Reviews.Average(review => review.Rating));
 }
示例#2
0
 public double GetAvgRating()
 {
     if (Reviews == null || Reviews.Count == 0)
     {
         return(0.0f);
     }
     return(Math.Round(Reviews.Average(x => x.GetRating()), 2));
 }
示例#3
0
 public void OnGet(int id)
 {
     Album   = _albumService.GetAlbumByID(id);
     Reviews = _reviewService.GetReviews().Where(r => r.Album.AlbumID == id);
     //List<Review> test = new List<Review>();
     //test = Reviews.Where(r => r.ReviewID == id);
     if (Reviews.Count() != 0)
     {
         Rating = Reviews.Average(r => r.StarRating);
     }
 }
 public double?GetAverageGrade()
 {
     if (Reviews.Any())
     {
         return(Math.Round(Reviews.Average(g => g.Grade), 1));
     }
     else
     {
         return(null);
     }
 }
示例#5
0
 public string AverageRating()
 {
     if (Reviews.Count() > 0)
     {
         var rating = Reviews.Average(r => r.Rating).ToString();
         return(rating);
     }
     else
     {
         return("Not rated");
     }
 }
示例#6
0
 public void SetRating()
 {
     if (Reviews.Count == 0)
     {
         _rating = null;
     }
     else
     {
         _rating = Reviews.Average(r => r.Rating);
         _rating = Math.Round((double)_rating, 1);
     }
 }
示例#7
0
 public virtual void CountRating()
 {
     Rating = (int)(Reviews.Count == 0 ? 0 : Reviews.Average(x => x.Rating));
 }
示例#8
0
 /// <summary>
 /// Calculates the average rating of this product <see cref="Reviews"/> property.
 /// </summary>
 /// <returns>Average rating of this product.</returns>
 public double GetAverageRating()
 {
     return(Reviews is null || Reviews.Count == 0 ?
            -1 : Reviews.Average(r => r.Rating));
 }