コード例 #1
0
        public static double GetApprovalPercentage(this PromotionCampaignSummary campaign)
        {
            var totalApprovals = campaign.CommentCounts
                                 .Where(x => x.Key == PromotionSentiment.Approve)
                                 .Select(x => x.Value)
                                 .Sum();

            double totalVotes = GetTotalVotes(campaign);

            return(totalApprovals / totalVotes);
        }
コード例 #2
0
 public static TimeSpan GetTimeUntilCampaignCanBeClosed(this PromotionCampaignSummary campaign)
 {
     return(campaign.CreateAction.Created.Add(CampaignAcceptCooldown) - DateTimeOffset.Now);
 }
コード例 #3
0
 public static int GetNumberOfOppositions(this PromotionCampaignSummary campaign)
 {
     return(campaign.CommentCounts
            .Where(x => x.Key == PromotionSentiment.Oppose)
            .Sum(x => x.Value));
 }
コード例 #4
0
 public static int GetTotalVotes(this PromotionCampaignSummary campaign)
 {
     return(campaign.CommentCounts
            .Select(x => x.Value)
            .Sum());
 }
コード例 #5
0
 /// <summary>
 /// Get the total count of comments that were not abstaining
 /// </summary>
 public static int GetTotalVotes(this PromotionCampaignSummary campaign)
 {
     return(campaign.CommentCounts
            .Where(x => x.Key != PromotionSentiment.Abstain)
            .Sum(x => x.Value));
 }