public RewardPointsResult_UT()
 {
     _calculator = new RewardPointsCalculator();
 }
 public MonthlyRewardPoints(IRewardPointsCalculator calculator, IGrouping <int, Transaction> month)
 {
     MonthName    = DateTimeFormatInfo.CurrentInfo.GetMonthName(month.Key);
     PointsEarned = month.Sum(t => calculator.CalculatePoints(t));
 }
Beispiel #3
0
 public RewardsService(ITransactionRepository transactionRepo, IRewardPointsCalculator calculator, ICustomerRepository customerData)
 {
     _transactionData = transactionRepo;
     _calculator      = calculator;
     _customerData    = customerData;
 }
Beispiel #4
0
        public RewardPointsResult(Customer customer, IEnumerable <Transaction> transactions, IRewardPointsCalculator calculator) : this()
        {
            CustomerId = customer.CustomerId;
            FirstName  = customer.FirstName;
            LastName   = customer.LastName;

            TotalRewardsPoints = transactions.Sum(t => calculator.CalculatePoints(t));

            var monthGroups = transactions.GroupBy(t => t.PurchaseDate.Month);

            foreach (var month in monthGroups)
            {
                MonthlyTotals.Add(new MonthlyRewardPoints(calculator, month));
            }
        }