Example #1
0
        public static string WinningRuleDescription(this WinningRule rule, string productName)
        {
            var comparisonInterpreted = ComparisonOperatorInterpreted(rule.Comparison);
            var periodInterpreted     = PeriodInterpereted(rule.Period);

            return(string.Format("product \"{0}\" with winnings amount {1} {2} in the period of {3}.",
                                 productName,
                                 comparisonInterpreted,
                                 rule.Amount,
                                 periodInterpreted));
        }
Example #2
0
        private DateTimeOffset?GetEndDate(WinningRule rule)
        {
            var now = DateTimeOffset.Now;

            switch (rule.Period)
            {
            case PeriodEnum.Last7Days:
            case PeriodEnum.Last14Days:
            case PeriodEnum.CurrentYear:
            case PeriodEnum.FromSignUp:
                return(now);

            case PeriodEnum.CustomDate:
                return(rule.EndDate);
            }
            return(null);
        }
Example #3
0
        private DateTimeOffset?GetStartDate(WinningRule rule, Guid playerId)
        {
            var now = DateTimeOffset.Now;

            switch (rule.Period)
            {
            case PeriodEnum.Last7Days:
                return(now.AddDays(-7));

            case PeriodEnum.Last14Days:
                return(now.AddDays(-14));

            case PeriodEnum.CurrentYear:
                return(new DateTime(now.Year, 1, 1));

            case PeriodEnum.FromSignUp:
                var player = _paymentRepository.Players.Single(o => o.Id == playerId);
                return(player.DateRegistered.LocalDateTime);

            case PeriodEnum.CustomDate:
                return(rule.StartDate);
            }
            return(null);
        }