コード例 #1
0
 public double GetAverageRating()
 {
     if (Ratings.Count() == 0)
     {
         return(0);
     }
     return(Ratings.Average(r => r.RatingNumber));
 }
コード例 #2
0
ファイル: Release.cs プロジェクト: mojinxun/Inmeta.VSGallery
        public double GetAverageRating()
        {
            if (!Ratings.Any())
            {
                return(0);
            }

            return(Ratings.Average(r => r.Rating));
        }
コード例 #3
0
 public void WriteRating(int userId, double newRating)
 {
     if (HasUserWrittenRating(userId))
     {
         Ratings.FirstOrDefault(c => c.UserId == userId && c.StoryId == this.Id).Score = newRating;
         AverageRating = Ratings.Average(r => r.Score);
     }
     else
     {
         Ratings.Add(new Rating()
         {
             StoryId = this.Id, UserId = userId, Score = newRating
         });
         AverageRating = ((AverageRating * (NumberOfRatings - 1)) + newRating) / NumberOfRatings;
     }
 }
コード例 #4
0
 public double GetAverageRate()
 {
     return(Ratings.Average());
 }
コード例 #5
0
ファイル: Product.cs プロジェクト: sheaft-app/api
 private void RefreshRatings()
 {
     Rating       = Ratings.Any() ? Ratings.Average(r => r.Value) : (decimal?)null;
     RatingsCount = Ratings.Count;
 }