private async Task loadSender(NotificationView notification)
 {
     notification.Sender =
         AccountViewFactory.Create(await accounts.GetObject(notification.SenderAccountId));
     notification.Sender.AspNetUser =
         await userManager.FindByIdAsync(notification.Sender.AspNetUserId);
 }
        public void CreateTest()
        {
            var r = GetRandom.Object <AccountData>();
            var o = new Account(r);
            var v = AccountViewFactory.Create(o);

            Assert.AreEqual(v.Type, o.Data.Type);
            Assert.AreEqual(v.ValidFrom, o.Data.ValidFrom);
            Assert.AreEqual(v.ValidTo, o.Data.ValidTo);
            Assert.AreEqual(v.Status, o.Data.Status);
            Assert.AreEqual(v.Balance, o.Data.Balance);
            Assert.AreEqual(v.AspNetUserId, o.Data.AspNetUserId);
        }
Esempio n. 3
0
        private async Task loadSenderAndReceiver(RequestTransactionViewsList viewList)
        {
            foreach (var request in viewList)
            {
                request.SenderAccount =
                    AccountViewFactory.Create(await accounts.GetObject(request.SenderAccountId));
                request.SenderAccount.AspNetUser =
                    await userManager.FindByIdAsync(request.SenderAccount.AspNetUserId);

                request.ReceiverAccount =
                    AccountViewFactory.Create(await accounts.GetObject(request.ReceiverAccountId));
                request.ReceiverAccount.AspNetUser =
                    await userManager.FindByIdAsync(request.ReceiverAccount.AspNetUserId);
            }
        }
Esempio n. 4
0
        public async Task <IActionResult> Index(string id, string sortOrder = null,
                                                string currentFilter        = null,
                                                string searchString         = null, int?page = null)
        {
            ViewData["CurrentSort"]       = sortOrder;
            ViewData["SortValidFrom"]     = string.IsNullOrEmpty(sortOrder) ? "validFrom_desc" : "";
            ViewData["SortSenderAccount"] =
                sortOrder == "senderAccount" ? "senderAccount_desc" : "senderAccount";
            ViewData["SortExplanation"] =
                sortOrder == "explanation" ? "explanation_desc" : "explanation";
            ViewData["SortAmount"] = sortOrder == "amount" ? "amount_desc" : "amount";
            transactions.SortOrder = sortOrder != null && sortOrder.EndsWith("_desc")
                ? SortOrder.Descending
                : SortOrder.Ascending;

            var loggedInUser = await userManager.GetUserAsync(HttpContext.User);

            var accIds = new List <string>();
            var accs   = await accounts.LoadAccountsForUser(loggedInUser.Id);

            foreach (var acc in accs)
            {
                accIds.Add(acc.Data.ID);
            }
            ViewBag.Accounts = accIds;

            if (id == null)
            {
                id = accIds.FirstOrDefault() ?? "Unspecified";
                return(RedirectToActionPermanent("Index", new { id }));
            }

            transactions.SortFunction = getSortFunction(sortOrder, id);
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewData["CurrentFilter"] = searchString;
            transactions.SearchString = searchString;
            transactions.PageIndex    = page ?? 1;


            BankAccount = await accounts.GetObject(id);

            var l = await transactions.LoadTransactionsForAccount(id);

            var viewList = new TransactionViewsList(l);

            foreach (var transaction in viewList)
            {
                transaction.SenderAccount =
                    AccountViewFactory.Create(await accounts.GetObject(transaction.SenderAccountId));
                transaction.SenderAccount.AspNetUser =
                    await userManager.FindByIdAsync(transaction.SenderAccount.AspNetUserId);

                transaction.ReceiverAccount =
                    AccountViewFactory.Create(await accounts.GetObject(transaction.ReceiverAccountId));
                transaction.ReceiverAccount.AspNetUser =
                    await userManager.FindByIdAsync(transaction.ReceiverAccount.AspNetUserId);

                adjustAmountIfUserIsTransactionSender(transaction, id);
            }

            return(View(viewList));
        }
        public async Task <IActionResult> Deactivate(string id)
        {
            var c = await repository.GetObject(id);

            return(View(AccountViewFactory.Create(c)));
        }