예제 #1
0
        public async Task <bool> UpdateWallet(string guid, string name, decimal balance, string currency, string owner, string description, List <DBTransaction> transactions)
        {
            DBWallet wallet = new DBWallet(Guid.Parse(guid), name, balance, currency, owner, description, transactions);
            await _storage.AddOrUpdateAsync(wallet);

            return(true);
        }
예제 #2
0
 public WalletDetailsViewModel(DBWallet wallet, WalletService ws, Action <WalletDetailsViewModel> DeleteCurrentWallet)
 {
     _service     = ws;
     _wallet      = wallet;
     UpdateWallet = new DelegateCommand(UpdateCurrentWallet);
     //DeleteWallet = new DelegateCommand(DeleteCurrentWallet);
     DeleteWallet = new DelegateCommand(async() => DeleteCurrentWallet(this));
 }
예제 #3
0
 public TransactionDetailsViewModel(DBTransaction transaction, TransactionService ws, WalletService wlts, DBWallet wallet, Action <TransactionDetailsViewModel> DeleteCurrentTransaction)
 {
     _service          = ws;
     _serviceW         = wlts;
     _wallet           = wallet;
     _transaction      = transaction;
     UpdateTransaction = new DelegateCommand(UpdateCurrentTransaction);
     DeleteTransaction = new DelegateCommand(async() => DeleteCurrentTransaction(this));
 }
예제 #4
0
        public async Task <bool> AddWalletsAsync(DBWallet wallet)
        {
            if (String.IsNullOrWhiteSpace(wallet.Name) || wallet.Balance < 0)
            {
                throw new ArgumentException("Name or Balance is Empty.");
            }

            await _storage.AddOrUpdateAsync(wallet);

            return(true);
        }
예제 #5
0
        public async Task SaveChanges()
        {
            await _storage.DeleteAllFiles(User.Id.ToString("N"));

            foreach (var wallet in Wallets)
            {
                var dbWallet = new DBWallet(wallet.Name, wallet.Owner.Id.ToString("N"),
                                            wallet.Description, wallet.InitialBalance,
                                            wallet.CurrentBalance, wallet.MainCurrency,
                                            wallet.Id, wallet.AvailabilityOfCategories);
                await _storage.AddOrUpdateAsync(dbWallet);
            }
        }
예제 #6
0
        public async void AddNewWallet()
        {
            try
            {
                IsWalletPanelEnabled = false;
                DBWallet w = new DBWallet(Guid.NewGuid(), "My wallet", 0, "UAH", _currentUser.Login, "Here you can add description.", new List <DBTransaction>());
                await _serviceWallet.AddWalletsAsync(w);

                Wallets.Add(new WalletDetailsViewModel(w, _serviceWallet, DeleteCurrentWallet));
                RaisePropertyChanged(nameof(Wallets));
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Wallet add was failed: {ex.Message}");
                return;
            }
            finally
            {
                IsWalletPanelEnabled = true;
            }
            MessageBox.Show($"Wallet was added successfully!");
        }
예제 #7
0
        public void TestAddingWallets()
        {
            //
            var testDBWallet = new DBWallet
            {
                Balance       = 120,
                BasicCurrency = "UAH",
                WalletGuid    = Guid.NewGuid(),
                Description   = "",
                Name          = "Name",
                OwnerEmail    = "OwnerEmail"
            };

            //
            WalletsHandler walletsHandler = new WalletsHandler();
            var            filename       = @"../../../DataBase/Wallet/wallets.json";

            walletsHandler.Filename = filename;
            walletsHandler.write(testDBWallet);

            //
            Assert.NotNull(walletsHandler.Find("OwnerEmail", "Name").Result);
        }