private void LoadRating(int photoID) { // Show rating try { var photoRating = new PhotoRating(photoID); Rating = photoRating.AverageVote; Votes = photoRating.Votes; } catch (NotFoundException) { Rating = 0; Votes = 0; } }
private void LoadRating(int photoID) { hidcurrentPhotoID.Value = photoID.ToString(); // Show rating try { var photoRating = new PhotoRating(photoID); lblRatingAverage.Text = String.Format( Lang.Trans("{0} ({1} votes)"), photoRating.AverageVote.ToString("0.00"), photoRating.Votes); } catch (NotFoundException) { lblRatingAverage.Text = Lang.Trans("no rating"); } // Show voting form if (CurrentUserSession != null && CurrentUserSession.Username != User.Username && ((CurrentUserSession.Level != null && CurrentUserSession.Level.Restrictions.CanRatePhotos) || CurrentUserSession.CanRatePhotos() == PermissionCheckResult.Yes) && Config.Ratings.EnablePhotoRatings) { try { PhotoRating.FetchVote(((PageBase)Page).CurrentUserSession.Username, photoID); pnlRatePhoto.Visible = false; } catch (NotFoundException) { pnlRatePhoto.Visible = true; } } else { pnlRatePhoto.Visible = false; } }