コード例 #1
0
ファイル: VoteController.cs プロジェクト: lenwen/mvcforum
 public PartialViewResult GetVotes(VoteUpViewModel voteUpViewModel)
 {
     if (Request.IsAjaxRequest())
     {
         var post = _postService.Get(voteUpViewModel.Post);
         var positiveVotes = post.Votes.Count(x => x.Amount > 0);
         var negativeVotes = post.Votes.Count(x => x.Amount <= 0);
         var viewModel = new ShowVotesViewModel { DownVotes = negativeVotes, UpVotes = positiveVotes};
         return PartialView(viewModel);
     }
     return null;
 }
コード例 #2
0
 public PartialViewResult GetVotes(EntityIdViewModel voteUpViewModel)
 {
     if (Request.IsAjaxRequest())
     {
         var post          = _postService.Get(voteUpViewModel.Id);
         var positiveVotes = post.Votes.Count(x => x.Amount > 0);
         var negativeVotes = post.Votes.Count(x => x.Amount <= 0);
         var viewModel     = new ShowVotesViewModel {
             DownVotes = negativeVotes, UpVotes = positiveVotes
         };
         return(PartialView(viewModel));
     }
     return(null);
 }