private void BindRating() { ContentRatingStats ratingStats = ContentRating.GetStats(ContentGuid); UserRating.CurrentRating = ratingStats.AverageRating; UserRating.JsonUrl = jsonServiceUrl; UserRating.ContentId = ContentGuid.ToString(); UserRating.TotalVotesElementId = lblRatingVotes.ClientID; UserRating.CommentsEnabled = allowFeedback; litRating.Text = ratingStats.AverageRating.ToString(CultureInfo.InvariantCulture); lblRatingVotes.Text = string.Format(CultureInfo.InvariantCulture, Resource.RatingCountFormat, ratingStats.TotalVotes); if (WebUser.IsAdminOrContentAdmin) { //lnkRatingsReview.Text = lblRatingVotes.Text; UserRating.TotalVotesElementId = lnkResults.ClientID; lblRatingVotes.Visible = false; //lnkRatingsReview.Visible = true; //lnkRatingsReview.NavigateUrl = SiteUtils.GetNavigationSiteRoot() + "/Dialog/ContentRatingsDialog.aspx?c=" + ContentGuid.ToString(); //lnkRatingsReview.ToolTip = Resource.RatingReviewsLink; //lnkRatingsReview.DialogCloseText = Resource.CloseDialogButton; lnkResults.Text = lblRatingVotes.Text; lnkResults.Visible = true; lnkResults.NavigateUrl = SiteUtils.GetNavigationSiteRoot() + "/Dialog/ContentRatingsDialog.aspx?c=" + ContentGuid.ToString(); lnkResults.ToolTip = Resource.RatingReviewsLink; } }
private void DoRating(HttpContext context) { SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); if (siteSettings == null) { return; } Guid userGuid = Guid.Empty; if (context.Request.IsAuthenticated) { SiteUser currentUser = SiteUtils.GetCurrentSiteUser(); if (currentUser != null) { userGuid = currentUser.UserGuid; if (emailAddress.Length == 0) { emailAddress = currentUser.Email; } } } ContentRating.RateContent( siteSettings.SiteGuid, contentGuid, userGuid, rating, emailAddress, comments, SiteUtils.GetIP4Address(), WebConfigSettings.MinutesBetweenAnonymousRatings ); ContentRatingStats ratingStats = ContentRating.GetStats(contentGuid); avgRating = ratingStats.AverageRating; totalVotes = ratingStats.TotalVotes; }