Example #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);
            }
        }
Example #2
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);
        }