private ReviewsPart BuildStars(ReviewsPart part, string displayType) { part.Rating.CurrentVotingResult = _votingService.GetResult(part.ContentItem.Id, "average") ?? new ResultRecord(); // get the user's vote var currentUser = _orchardServices.WorkContext.CurrentUser; if (currentUser != null) { var userRating = _votingService.Get(vote => vote.Username == currentUser.UserName && vote.ContentItemRecord == part.ContentItem.Record).FirstOrDefault(); if (userRating != null) { part.Rating.UserRating = userRating.Value; } else { part.Rating.UserRating = 0; } } if (displayType == "Detail" || displayType == "Details") { BuildReviews(part, part.Rating.CurrentVotingResult, currentUser); } return(part); }
protected override DriverResult Display(UserViewPart part, string displayType, dynamic shapeHelper) { var resultRecord = _votingService.GetResult(part.ContentItem.Id, "sum", Constants.Dimension); part.TotalViews = resultRecord == null ? 0 : (int)resultRecord.Value; return(Combined(ContentShape("Parts_UserView_Summary", () => shapeHelper.Parts_UserView_Summary(TotalViews: part.TotalViews)), ContentShape("Parts_UserView_SummaryAdmin", () => shapeHelper.Parts_UserView_SummaryAdmin(TotalViews: part.TotalViews)))); }
public double GetResult(ContentItem contentItem) { var result = _votingService.GetResult(contentItem.Id, "sum", Constants.Voting.RatingConstant); if (result == null) { return(0D); } return(result.Value); }
private FavoritePart BuildVoteUpDown(FavoritePart part) { var currentUser = _authenticationService.GetAuthenticatedUser(); if (currentUser != null) { var resultRecord = _votingService.GetResult(part.ContentItem.Id, "sum", Constants.Dimension); part.IsFavorite = (resultRecord != null && resultRecord.Value > 0.0); part.NumberOfFavorites = _votingService.Get(vote => vote.Username == currentUser.UserName && vote.Dimension == Constants.Dimension).Sum(o => o.Value); } return(part); }