コード例 #1
0
ファイル: RateController.cs プロジェクト: NickAndersonX/xodb
 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
ファイル: RateController.cs プロジェクト: NickAndersonX/xodb
 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);
         }
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }