Ejemplo n.º 1
0
 private async void SignIn()
 {
     if (String.IsNullOrWhiteSpace(Login) || String.IsNullOrWhiteSpace(Password))
     {
         MessageBox.Show("Login or password is empty");
     }
     else
     {
         var  authService = new AuthenticationService();
         User user        = null;
         try
         {
             IsEnabled = false;
             user      = await Task.Run(() => authService.Authenticate(_authUser));
         }
         catch (Exception ex)
         {
             MessageBox.Show($"Sign in failed {ex.Message}");
             return;
         }
         finally // is done independently from exception
         {
             IsEnabled = true;
         }
         MessageBox.Show($"Sign in was successful for user {user.FirstName} {user.LastName}");
         _gotoWalletsView.Invoke();
         WalletsViewModel.UpdateWalletsCollection(); // here collection of wallets for concrete user is updated because constuctor does it only one time
     }
 }
Ejemplo n.º 2
0
        public ActionResult UserAccount(Guid id)
        {
            var coinList = FoundationDB.CryptocurrencyDb.GetList();
            var list     = FiiiPayDB.DB.Queryable <UserWallets>().Where(t => t.UserAccountId == id).ToList();
            List <WalletsViewModel> walletsList = new List <WalletsViewModel>();

            foreach (var item in list)
            {
                WalletsViewModel model = new WalletsViewModel();
                model.Balance       = item.Balance;
                model.CurrencyName  = coinList.Where(t => t.Id == item.CryptoId).Select(t => t.Name).FirstOrDefault();
                model.FrozenBalance = item.FrozenBalance;
                walletsList.Add(model);
            }
            ViewBag.WalletsList = walletsList;
            return(View());
        }
Ejemplo n.º 3
0
        public IActionResult Wallets(bool update = false)
        {
            var user = GetUser(required: true).Result;

            var chainBalances = new Dictionary <string, ChainWalletBalance>();
            var fiatBalances  = new Dictionary <string, FiatWalletBalance>();

            foreach (var asset in _settings.Assets.Keys)
            {
                try
                {
                    if (_walletProvider.IsChain(asset))
                    {
                        if (update)
                        {
                            _walletProvider.UpdateBlockchainWallet(asset);
                        }

                        var wallet  = _walletProvider.GetFastChain(asset);
                        var balance = new ChainWalletBalance {
                            Total = 0, Consolidated = 0
                        };
                        balance.Total        = wallet.GetBalance();
                        balance.Consolidated = wallet.GetBalance(_walletSettings.ConsolidatedFundsTag);
                        balance.Wallet       = _walletProvider.GetChain(asset);
                        chainBalances[asset] = balance;
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, "Could not obtain blockchain wallet for asset '{0}'", asset);
                }
                try
                {
                    if (_walletProvider.IsFiat(asset))
                    {
                        var wallet  = _walletProvider.GetFastFiat(asset);
                        var balance = new FiatWalletBalance {
                            Total = 0
                        };
                        balance.Total       = wallet.GetBalance();
                        balance.Wallet      = _walletProvider.GetFiat(asset);
                        fiatBalances[asset] = balance;
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, "Could not obtain fiat wallet for asset '{0}'", asset);
                }
            }

            var model = new WalletsViewModel
            {
                User          = user,
                AssetSettings = _settings.Assets,
                ChainBalances = chainBalances,
                FiatBalances  = fiatBalances
            };

            return(View(model));
        }
Ejemplo n.º 4
0
 public WalletsPage()
 {
     InitializeComponent();
     BindingContext = new WalletsViewModel(Navigation,
                                           App.Kernel.Get <ISmartNavigator>(), App.Kernel.Get <IPageNavigator>());
 }