private void Vote(ContentItem content, IUser currentUser, int rating, VoteRecord currentVote) { if (currentVote != null) { _votingService.ChangeVote(currentVote, rating); } else { _votingService.Vote(content, currentUser.UserName, HttpContext.Request.UserHostAddress, rating); } }
private void Vote(ContentItem content, IUser currentUser, int rating, VoteRecord currentVote) { if (currentVote != null) { _votingService.ChangeVote(currentVote, rating); } else { _votingService.Vote(content, currentUser.UserName, HttpContext.Request.UserHostAddress, rating); } // I need to evict the content item from the cache because in case of authenticated caching, the review list doesn't get to be refreshed. _cacheService.RemoveByTag(content.Id.ToString()); }
private void Vote(string userName, UserViewPart part, UserViewTypePartSettings settings) { var currentVote = _votingService.Get(vote => vote.ContentItemRecord == part.ContentItem.Record && vote.Username == userName && vote.Dimension == Constants.Dimension).FirstOrDefault(); if (currentVote != null && settings.AllowMultipleViewsFromSameUserToCount) { _votingService.ChangeVote(currentVote, (currentVote.Value + 1)); } else if (currentVote == null) { _votingService.Vote(part.ContentItem, userName, _orchardServices.WorkContext.HttpContext.Request.UserHostAddress, 1, Constants.Dimension); } }
public void RegisterUserVote(IUser user, ContentItem contentItem, int rating) { var currentVote = GetUserVote(user, contentItem); if (currentVote != null && (currentVote.Value + rating == 0)) { _votingService.RemoveVote(currentVote); } else { if (currentVote != null) { _votingService.ChangeVote(currentVote, rating); } else { _votingService.Vote(contentItem, user.UserName, _httpContextAccessor.Current().Request.UserHostAddress, rating, Constants.Voting.RatingConstant); } } }