コード例 #1
0
        public static async Task AddTransactionAsync(Transaction transaction, bool raisechangedevent = true)
        {
            Globals.DbContext.Transactions.Add(transaction);
            await Globals.DbContext.SaveChangesAsync();

            Globals.AppViewModel.TransactionsViewModel.Transactions =
                new ObservableCollection <Transaction>(Globals.DbContext.Transactions);
            Globals.AppViewModel.TransactionsViewModel.RecentTransactions =
                new ObservableCollection <Transaction>((from t in Globals.DbContext.Transactions
                                                        orderby t.Created descending
                                                        select t).Take(20));
            if (raisechangedevent)
            {
                Globals.AppViewModel.TransactionsViewModel.RaisePropertyChanged("Transactions");
                Globals.AppViewModel.TransactionsViewModel.RaisePropertyChanged("RecentTransactions");
            }
            // we check both sides since we could potentially be sending to one of our own accounts
            var istx =
                (from a in Globals.AppViewModel.AccountsViewModel.Accounts
                 where a.Address == transaction.Sender
                 select a).Any();
            var isrx =
                (from a in Globals.AppViewModel.AccountsViewModel.Accounts
                 where a.Address == transaction.Receiver
                 select a).Any();

            if (istx)
            {
                await AccountsViewModel.UpdateAccount(transaction.Sender);
            }
            if (isrx)
            {
                await AccountsViewModel.UpdateAccount(transaction.Receiver);
            }
        }
コード例 #2
0
 public AppViewModel()
 {
     _accountsViewModel          = new AccountsViewModel();
     _transactionsViewModel      = new TransactionsViewModel();
     Globals.OnNewBlockReceived += Globals_OnNewBlockReceived;
     _statustext = "Loading...";
     _accountsViewModel.PropertyChanged     += ViewModel_PropertyChanged;
     _transactionsViewModel.PropertyChanged += ViewModel_PropertyChanged;
 }