Beispiel #1
0
        private List <string> GetSecondaryPayments(int accountId)
        {
            var allPayments = new List <PaymentViewModel>();
            var allPayment  = new List <LiveTilesPaymentInfo>();

            allPayments.AddRange(crudService.ReadManyNoTracked <PaymentViewModel>()
                                 .Where(x => x.ChargedAccountId == accountId)
                                 .ToList());
            try
            {
                allPayments.AddRange(crudService.ReadManyNoTracked <PaymentViewModel>()
                                     .Where(x => x.TargetAccountId == accountId)
                                     .ToList());
            }
            catch (Exception e)
            {
                logger.Fatal(e);
            }

            foreach (PaymentViewModel item in allPayments)
            {
                if (item.IsRecurring)
                {
                    allPayment.AddRange(GetRecurrence(item));
                }
                else
                {
                    var tileInfo = new LiveTilesPaymentInfo
                    {
                        Chargeaccountname = item.ChargedAccount.Name,
                        Amount            = item.Amount,
                        Date = item.Date.Date,
                        Type = item.Type
                    };
                    allPayment.Add(tileInfo);
                }
            }

            List <LiveTilesPaymentInfo> payments = allPayment.OrderByDescending(x => x.Date.Date)
                                                   .ThenBy(x => x.Date.Date <= DateTime.Today.Date)
                                                   .Take(NUMBER_OF_PAYMENTS)
                                                   .ToList();

            List <string> returnList = payments.Select(x => LiveTileHelper.GetTileText(TileSizeOption.Large, x)).ToList();

            for (int i = returnList.Count; i < NUMBER_OF_PAYMENTS - 1; i++)
            {
                returnList.Add(string.Empty);
            }

            return(returnList);
        }
Beispiel #2
0
        private async Task <List <string> > GetPaymentsAsync(TileSizeOption tileSize,
                                                             PaymentInformation paymentInformation)
        {
            List <AccountViewModel> acct = await crudService.ReadManyNoTracked <AccountViewModel>()
                                           .ToListAsync();

            var allPayments = new List <PaymentViewModel>();
            var allPayment  = new List <LiveTilesPaymentInfo>();

            foreach (AccountViewModel item in acct)
            {
                allPayments.AddRange(crudService.ReadManyNoTracked <PaymentViewModel>()
                                     .Where(x => x.ChargedAccountId == item.Id)
                                     .ToList());

                // We have to catch here, since otherwise an Exception is thrown when no payments are there.
                try
                {
                    allPayments.AddRange(crudService.ReadManyNoTracked <PaymentViewModel>()
                                         .Where(x => x.TargetAccountId == item.Id)
                                         .ToList());
                }
                catch (Exception e)
                {
                    logger.Fatal(e);
                }
            }

            foreach (PaymentViewModel item in allPayments)
            {
                if (item.IsRecurring)
                {
                    allPayment.AddRange(GetRecurrence(item));
                }
                else
                {
                    var tileInfo = new LiveTilesPaymentInfo
                    {
                        Chargeaccountname = item.ChargedAccount.Name,
                        Amount            = item.Amount,
                        Date = item.Date.Date,
                        Type = item.Type
                    };
                    allPayment.Add(tileInfo);
                }
            }

            List <LiveTilesPaymentInfo> payments;

            if (paymentInformation == PaymentInformation.Previous)
            {
                payments = allPayment.OrderByDescending(x => x.Date.Date)
                           .ThenBy(x => x.Date.Date <= DateTime.Today.Date)
                           .Take(NUMBER_OF_PAYMENTS)
                           .ToList();
            }
            else
            {
                payments = allPayment.OrderBy(x => x.Date.Date)
                           .ThenBy(x => x.Date.Date >= DateTime.Today.Date)
                           .Take(NUMBER_OF_PAYMENTS)
                           .ToList();
            }

            List <string> returnList = payments.Select(x => LiveTileHelper.GetTileText(tileSize, x)).ToList();

            for (int i = returnList.Count; i < NUMBER_OF_PAYMENTS - 1; i++)
            {
                returnList.Add(string.Empty);
            }

            allPayments.Clear();
            return(returnList);
        }
Beispiel #3
0
        private async Task <List <string> > GetPaymentsAsync(TileSizeOptions tileSize,
                                                             PaymentInformation paymentInformation)
        {
            List <AccountViewModel> acct = await crudService.ReadManyNoTracked <AccountViewModel>()
                                           .ToListAsync()
                                           .ConfigureAwait(false);

            List <PaymentViewModel>     allpayments = new List <PaymentViewModel>();
            List <LiveTilesPaymentInfo> allpayment  = new List <LiveTilesPaymentInfo>();

            foreach (AccountViewModel item in acct)
            {
                allpayments.AddRange(crudService.ReadManyNoTracked <PaymentViewModel>()
                                     .Where(x => x.ChargedAccountId == item.Id)
                                     .ToList());

                allpayments.AddRange(crudService.ReadManyNoTracked <PaymentViewModel>()
                                     .Where(x => x.TargetAccountId == item.Id)
                                     .ToList());
            }

            foreach (PaymentViewModel item in allpayments)
            {
                if (item.IsRecurring)
                {
                    allpayment.AddRange(GetRecurrence(item));
                }
                else
                {
                    var tileinfo = new LiveTilesPaymentInfo();
                    tileinfo.Chargeaccountname = item.ChargedAccount.Name;
                    tileinfo.Amount            = item.Amount;
                    tileinfo.Date = item.Date.Date;
                    tileinfo.Type = item.Type;
                    allpayment.Add(tileinfo);
                }
            }

            List <LiveTilesPaymentInfo> payments;

            if (paymentInformation == PaymentInformation.Previous)
            {
                payments = allpayment.OrderByDescending(x => x.Date.Date)
                           .ThenBy(x => x.Date.Date <= DateTime.Today.Date)
                           .Take(NUMBER_OF_PAYMENTS)
                           .ToList();
            }
            else
            {
                payments = allpayment.OrderBy(x => x.Date.Date)
                           .ThenBy(x => x.Date.Date >= DateTime.Today.Date)
                           .Take(NUMBER_OF_PAYMENTS)
                           .ToList();
            }

            List <string> returnList = payments.Select(x => LiveTileHelper.GetTileText(tileSize, x)).ToList();

            for (int i = returnList.Count; i < NUMBER_OF_PAYMENTS - 1; i++)
            {
                returnList.Add(string.Empty);
            }

            allpayments.Clear();
            return(returnList);
        }