Пример #1
0
 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);
     }
 }
Пример #2
0
 private void ClearRating(VoteRecord currentVote) {
     if (currentVote != null) {
         _votingService.RemoveVote(currentVote);
         foreach (var reviewRecord in _reviewRecordRepository.Fetch(rr => rr.VoteRecordId == currentVote.Id)) {
             _reviewRecordRepository.Delete(reviewRecord);
         }
     }
 }
        public void RemoveVote(VoteRecord vote) {

            foreach (var function in _functions) {
                _calculator.Calculate(new DeleteCalculus { Dimension = vote.Dimension, ContentId = vote.ContentItemRecord.Id, Vote = vote.Value, FunctionName = function.Name });
            }
            
            _voteRepository.Delete(vote);
            _eventHandler.VoteRemoved(vote);
        }
        public void ChangeVote(VoteRecord vote, double value) {
            var previousValue = value;

            foreach (var function in _functions) {
                _calculator.Calculate(new UpdateCalculus { Dimension = vote.Dimension, ContentId = vote.ContentItemRecord.Id, PreviousVote = vote.Value, Vote = value, FunctionName = function.Name });
            }

            vote.CreatedUtc = _clock.UtcNow;
            vote.Value = value;

            _eventHandler.VoteChanged(vote, previousValue);
        }
        public void Vote(Orchard.ContentManagement.ContentItem contentItem, string userName, string hostname, double value, string dimension = null) {
            var vote = new VoteRecord {
                Dimension = dimension,
                ContentItemRecord = contentItem.Record,
                ContentType = contentItem.ContentType,
                CreatedUtc = _clock.UtcNow,
                Hostname = hostname,
                Username = userName,
                Value = value
            };

            _voteRepository.Create(vote);

            foreach(var function in _functions) {
                _calculator.Calculate(new CreateCalculus { Dimension = dimension, ContentId = contentItem.Id, FunctionName = function.Name, Vote = value});
            }

            _eventHandler.Voted(vote);
        }