예제 #1
0
        public async Task <IActionResult> Transactions(string asset, string address, int offset = 0, int limit = 10)
        {
            var user = await GetUser(required : true);

            // get wallet address
            var        wallet = _walletProvider.GetChain(asset);
            var        addrs  = wallet.GetAddresses(user.Id);
            WalletAddr addr   = null;

            if (addrs.Any())
            {
                addr = addrs.First();
            }
            else
            {
                addr = wallet.NewAddress(user.Id);
            }

            var chainAssetSettings = _walletProvider.ChainAssetSettings(asset);

            var incommingTxs = wallet.GetAddrTransactions(addr.Address);

            if (incommingTxs != null)
            {
                incommingTxs = incommingTxs.Where(t => t.Direction == WalletDirection.Incomming).OrderByDescending(t => t.ChainTx.Date);
            }
            else
            {
                incommingTxs = new List <WalletTx>();
            }

            var model = new UserTransactionsViewModel
            {
                User                  = user,
                Asset                 = asset,
                DepositAddress        = addr.Address,
                ChainAssetSettings    = _walletProvider.ChainAssetSettings(asset),
                AssetSettings         = _settings.Assets[asset],
                Wallet                = wallet,
                TransactionsIncomming = incommingTxs.Skip(offset).Take(limit),
                TxsIncommingOffset    = offset,
                TxsIncommingLimit     = limit,
                TxsIncommingCount     = incommingTxs.Count(),
            };

            return(View(model));
        }
예제 #2
0
        public async Task <IActionResult> Index()
        {
            var username = userManager.GetUserName(HttpContext.User);

            if (username == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{userManager.GetUserId(User)}'.");
            }

            var transactions = await this.transactionService.GetUserTransactions(username);

            var amounts = await this.transactionService.GetAllAmounts(username, transactions.Currency);

            var model = new UserTransactionsViewModel(transactions, amounts);

            model.SortOrder = model.SortOrder ?? GlobalConstants.DefaultTransactionSorting;

            ViewData["CurrencySymbol"] = transactions.CurrencySymbol;

            return(View(model));
        }
        public UserTransactionsViewModelTests()
        {
            dialogServiceMock = new Mock <IPageDialogService>();

            email = "email";
            navigationParameters = new NavigationParameters {
                { email, "email" }
            };

            transactions = new List <Transaction>
            {
                new Transaction
                {
                    ReferenceNumber = "ReferenceNumber1",
                    TotalPrice      = 101,
                    Date            = DateTime.Parse("02/06/20 17:00:00")
                },
                new Transaction
                {
                    ReferenceNumber = "ReferenceNumber2",
                    TotalPrice      = 102,
                    Date            = DateTime.Parse("02/06/20 18:00:00")
                },
                new Transaction
                {
                    ReferenceNumber = "ReferenceNumber3",
                    TotalPrice      = 103,
                    Date            = DateTime.Parse("02/06/20 19:00:00")
                }
            };

            transactionServiceMock = new Mock <ITransactionService>();
            transactionServiceMock
            .Setup(ts => ts.GetTransactionsAsync(email))
            .ReturnsAsync(transactions);

            userTransactionsViewModel = new UserTransactionsViewModel(transactionServiceMock.Object, null, dialogServiceMock.Object);
        }
예제 #4
0
        public async Task <IActionResult> UpdateTable(TransactionsViewModel model)
        {
            var username = userManager.GetUserName(HttpContext.User);

            if (username == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{userManager.GetUserId(User)}'.");
            }

            if (!ModelState.IsValid)
            {
                ModelState.Clear();

                var oldTransactions = await this.transactionService.GetUserTransactions(username);

                var oldAmounts = await this.transactionService.GetAllAmounts(username, oldTransactions.Currency);

                var oldModel = new UserTransactionsViewModel(oldTransactions, oldAmounts);

                oldModel.SortOrder = model.SortOrder ?? GlobalConstants.DefaultTransactionSorting;

                ViewData["CurrencySymbol"] = oldTransactions.CurrencySymbol;

                return(PartialView("_TransactionHistoryTablePartial", oldModel));
            }

            var newTransactions = await this.transactionService.GetUserTransactions(username, model.PageNumber, model.PageSize, model.SortOrder);

            var newAmounts = await this.transactionService.GetAllAmounts(username, newTransactions.Currency);

            var newModel = new UserTransactionsViewModel(newTransactions, newAmounts);

            newModel.SortOrder = model.SortOrder;

            ViewData["CurrencySymbol"] = newTransactions.CurrencySymbol;

            return(PartialView("_TransactionHistoryTablePartial", newModel));
        }
예제 #5
0
        public IActionResult UserInspectWalletTxs(string id, string asset, int inOffset = 0, int inLimit = 10, int outOffset = 0, int outLimit = 10)
        {
            var user = GetUser(required: true).Result;

            if (_walletProvider.IsFiat(asset))
            {
                return(RedirectToAction("UserInspectFiatWalletTxs", new { id = id, asset = asset }));
            }

            // get wallet transactions
            var wallet = _walletProvider.GetChain(asset);
            var txsIn  = wallet.GetTransactions(id)
                         .Where(t => t.Direction == WalletDirection.Incomming).OrderByDescending(t => t.ChainTx.Date);
            var txsOutForUser = wallet.GetTransactions(_walletProvider.ConsolidatedFundsTag(), id).OrderByDescending(t => t.ChainTx.Date);

            ViewData["userid"] = id;
            var model = new UserTransactionsViewModel
            {
                User                  = user,
                Asset                 = asset,
                DepositAddress        = null,
                ChainAssetSettings    = _walletProvider.ChainAssetSettings(asset),
                AssetSettings         = _settings.Assets[asset],
                Wallet                = wallet,
                TransactionsIncomming = txsIn.Skip(inOffset).Take(inLimit),
                TxsIncommingOffset    = inOffset,
                TxsIncommingLimit     = inLimit,
                TxsIncommingCount     = txsIn.Count(),
                TransactionsOutgoing  = txsOutForUser.Skip(outOffset).Take(outLimit),
                TxsOutgoingOffset     = outOffset,
                TxsOutgoingLimit      = outLimit,
                TxsOutgoingCount      = txsOutForUser.Count(),
            };

            return(View(model));
        }