예제 #1
0
        public static string GetTileText(TileSizeOptions tileSize, LiveTilesPaymentInfo liveTileItem)
        {
            if (liveTileItem.Type == PaymentType.Income)
            {
                switch (tileSize)
                {
                case TileSizeOptions.Medium:
                    return(liveTileItem.Chargeaccountname + " +" + TruncateNumber(liveTileItem.Amount));

                case TileSizeOptions.Wide:
                case TileSizeOptions.Large:
                    return(string.Format(CultureInfo.InvariantCulture, Strings.LiveTileWideandLargeIncomePastText,
                                         liveTileItem.Amount.ToString("C2", CultureInfo.InvariantCulture),
                                         liveTileItem.Chargeaccountname, liveTileItem.Date.Date));

                default:
                    return(string.Empty);
                }
            }
            switch (tileSize)
            {
            case TileSizeOptions.Medium:
                return(liveTileItem.Chargeaccountname + " -" + TruncateNumber(liveTileItem.Amount));

            case TileSizeOptions.Wide:
            case TileSizeOptions.Large:
                return(string.Format(CultureInfo.InvariantCulture, Strings.LiveTileWideandLargePaymentPastText,
                                     liveTileItem.Amount.ToString("C2", CultureInfo.InvariantCulture),
                                     liveTileItem.Chargeaccountname));

            default:
                return(string.Empty);
            }
        }
예제 #2
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);
        }
예제 #3
0
        private DateTime CreateLiveTileInfos(PaymentViewModel payment, List <LiveTilesPaymentInfo> allPayment,
                                             DateTime startDate)
        {
            var liveTilesPaymentInfo = new LiveTilesPaymentInfo {
                Date              = startDate,
                Amount            = payment.RecurringPayment?.Amount ?? payment.Amount,
                Chargeaccountname = payment.RecurringPayment == null
                    ? payment.ChargedAccount.Name
                    : payment.RecurringPayment?.ChargedAccount.Name,
                Type = payment.RecurringPayment?.Type ?? payment.Type
            };

            allPayment.Add(liveTilesPaymentInfo);
            return(LiveTileHelper.AddDateByRecurrence(payment, startDate));
        }
예제 #4
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);
        }
예제 #5
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);
        }