예제 #1
0
        public void Recalculate(string[] productIds)
        {
            var reviews       = _customerReviewService.GetByProductIds(productIds);
            var activeReviews = reviews.Where(x => x.IsActive).ToArray();

            foreach (var productId in productIds)
            {
                var productReviews = activeReviews.Where(x => x.ProductId == productId);

                var rating = _ratingCalculator.CalcRating(productReviews);

                var productRating = AbstractTypeFactory <ProductRating> .TryCreateInstance();

                productRating.ProductId = productId;
                productRating.Rating    = rating;

                _productRatingService.SaveProductRating(productRating);
            }
        }