// Methods: public double GetAvgReviewRating() { if (Reviews.Count == 0) { return(0); } return(Reviews.Average(review => review.Rating)); }
public double GetAvgRating() { if (Reviews == null || Reviews.Count == 0) { return(0.0f); } return(Math.Round(Reviews.Average(x => x.GetRating()), 2)); }
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); } }
public string AverageRating() { if (Reviews.Count() > 0) { var rating = Reviews.Average(r => r.Rating).ToString(); return(rating); } else { return("Not rated"); } }
public void SetRating() { if (Reviews.Count == 0) { _rating = null; } else { _rating = Reviews.Average(r => r.Rating); _rating = Math.Round((double)_rating, 1); } }
public virtual void CountRating() { Rating = (int)(Reviews.Count == 0 ? 0 : Reviews.Average(x => x.Rating)); }
/// <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)); }