예제 #1
0
 public IEnumerable<TakenLoanPaymentStatistic> GetTakenLoanPaymentStatistics(IStatisticContext context)
 {
     var allTakenLoans = this.creditService.GetAllTakenLoans().ToList();
     var notOnTime =
         allTakenLoans.Where(x => x.TakeDate >= context.Start && x.TakeDate <= context.End)
             .Where(
                 x =>
                 x.Payments.Any(
                     payment => payment.Status == LoanPaymentStatus.Active && payment.Date < context.Today)).ToArray();
     var onTime = allTakenLoans.Except(notOnTime).ToArray();
     var result = new Collection<TakenLoanPaymentStatistic>
                      {
                          new TakenLoanPaymentStatistic
                              {
                                  PaymentCategory = "Not On Time",
                                  TakeCount = notOnTime.Count(),
                                  TotalAmount = notOnTime.Select(x => x.Amount).Sum()
                              },
                          new TakenLoanPaymentStatistic
                              {
                                  PaymentCategory = "On Time",
                                  TakeCount = onTime.Count(),
                                  TotalAmount = onTime.Select(x => x.Amount).Sum()
                              }
                      };
     return result;
 }
예제 #2
0
        public IEnumerable <TakenLoanPaymentStatistic> GetTakenLoanPaymentStatistics(IStatisticContext context)
        {
            var allTakenLoans = this.creditService.GetAllTakenLoans().ToList();
            var notOnTime     =
                allTakenLoans.Where(x => x.TakeDate >= context.Start && x.TakeDate <= context.End)
                .Where(
                    x =>
                    x.Payments.Any(
                        payment => payment.Status == LoanPaymentStatus.Active && payment.Date < context.Today)).ToArray();
            var onTime = allTakenLoans.Except(notOnTime).ToArray();
            var result = new Collection <TakenLoanPaymentStatistic>
            {
                new TakenLoanPaymentStatistic
                {
                    PaymentCategory = "Not On Time",
                    TakeCount       = notOnTime.Count(),
                    TotalAmount     = notOnTime.Select(x => x.Amount).Sum()
                },
                new TakenLoanPaymentStatistic
                {
                    PaymentCategory = "On Time",
                    TakeCount       = onTime.Count(),
                    TotalAmount     = onTime.Select(x => x.Amount).Sum()
                }
            };

            return(result);
        }
예제 #3
0
 public IEnumerable<PossiblePaymentsStatistic> GetPossiblePaymentsStatistics(IStatisticContext context)
 {
     var allTakenLoans = this.creditService.GetAllTakenLoans().ToList();
     var result = allTakenLoans.GroupBy(x => x.ProductLoan.Id).Select(x => new PossiblePaymentsStatistic
         {
             LoanProductName = x.First().ProductLoan.Name,
             TotalAmount = x.SelectMany(y => y.Payments
                 .Where(p => p.Date <= context.End && p.Date >= context.Start)
                 .Select(p => p.Amount))
                 .Sum()
         });
     return result;
 }
예제 #4
0
        public IEnumerable <PossiblePaymentsStatistic> GetPossiblePaymentsStatistics(IStatisticContext context)
        {
            var allTakenLoans = this.creditService.GetAllTakenLoans().ToList();
            var result        = allTakenLoans.GroupBy(x => x.ProductLoan.Id).Select(x => new PossiblePaymentsStatistic
            {
                LoanProductName = x.First().ProductLoan.Name,
                TotalAmount     = x.SelectMany(y => y.Payments
                                               .Where(p => p.Date <= context.End && p.Date >= context.Start)
                                               .Select(p => p.Amount))
                                  .Sum()
            });

            return(result);
        }
예제 #5
0
 public IEnumerable<SummaryLoanProductStatistic> GetSummaryLoanProductStatistics(IStatisticContext context)
 {
     var allTakenLoans = this.creditService.GetAllTakenLoans().ToList();
     //var allTakenLoans = new Collection<TakenLoan>
     //                        {
     //                            new TakenLoan
     //                                {
     //                                    Amount = 1000,
     //                                    Id = 1,
     //                                    ProductLoan = new LoanProduct
     //                                                      {
     //                                                          Id = 1,
     //                                                          Name = "a",
     //                                                          Status = LoanProductStatus.Active,
     //                                                      }
     //                                },
     //                            new TakenLoan
     //                                {
     //                                    Amount = 100,
     //                                    Id = 2,
     //                                    ProductLoan = new LoanProduct
     //                                                      {
     //                                                          Id = 2,
     //                                                          Name = "b",
     //                                                          Status = LoanProductStatus.Active,
     //                                                      }
     //                                }
     //                        };
     var statistics = allTakenLoans.Where(x => x.TakeDate >= context.Start && x.TakeDate <= context.End)
         .GroupBy(x => x.ProductLoan.Id).Select(x => new SummaryLoanProductStatistic
                                   {
                                       LoanProductId = x.First().ProductLoan.Id,
                                       LoanProductName = x.First().ProductLoan.Name,
                                       Status = x.First().ProductLoan.Status,
                                       TakeCount = x.Count(),
                                       TotalAmount = x.Select(takenLoan => takenLoan.Amount).ToArray().Sum()
                                   });
     return statistics;
 }
 public PlayerPlayedEventConsumer(IStatisticContext context, ILogger <PlayerPlayedEventConsumer> logger)
 {
     _context = context;
     _logger  = logger;
 }
예제 #7
0
        public IEnumerable <SummaryLoanProductStatistic> GetSummaryLoanProductStatistics(IStatisticContext context)
        {
            var allTakenLoans = this.creditService.GetAllTakenLoans().ToList();
            //var allTakenLoans = new Collection<TakenLoan>
            //                        {
            //                            new TakenLoan
            //                                {
            //                                    Amount = 1000,
            //                                    Id = 1,
            //                                    ProductLoan = new LoanProduct
            //                                                      {
            //                                                          Id = 1,
            //                                                          Name = "a",
            //                                                          Status = LoanProductStatus.Active,
            //                                                      }
            //                                },
            //                            new TakenLoan
            //                                {
            //                                    Amount = 100,
            //                                    Id = 2,
            //                                    ProductLoan = new LoanProduct
            //                                                      {
            //                                                          Id = 2,
            //                                                          Name = "b",
            //                                                          Status = LoanProductStatus.Active,
            //                                                      }
            //                                }
            //                        };
            var statistics = allTakenLoans.Where(x => x.TakeDate >= context.Start && x.TakeDate <= context.End)
                             .GroupBy(x => x.ProductLoan.Id).Select(x => new SummaryLoanProductStatistic
            {
                LoanProductId   = x.First().ProductLoan.Id,
                LoanProductName = x.First().ProductLoan.Name,
                Status          = x.First().ProductLoan.Status,
                TakeCount       = x.Count(),
                TotalAmount     = x.Select(takenLoan => takenLoan.Amount).ToArray().Sum()
            });

            return(statistics);
        }
 public GamePlayedEventConsumer(ILogger <GamePlayedEventConsumer> logger, IStatisticContext context)
 {
     _logger  = logger;
     _context = context;
 }