コード例 #1
0
        public async void Add()

        {
            if (String.IsNullOrEmpty(Name) ||
                String.IsNullOrEmpty(BasicCurrency) || String.IsNullOrEmpty(Description))
            {
                MessageBox.Show("Some fields are empty");
            }
            else
            {
                if (AlreadyExists())
                {
                    MessageBox.Show($"Wallet with name '{Name}' already exists");
                }
                else
                {
                    wallet = new lab.Wallet(CurrentInfo.Customer, Name, Convert.ToDouble(StartBalance), Description, BasicCurrency);
                    CurrentInfo.Customer.AddWallet(wallet);
                    WalletsHandler handler = new WalletsHandler();
                    handler.Filename = @"../../../DataBase/Wallet/Wallets.json";
                    await handler.write(new DBWallet(CurrentInfo.Customer.Email, wallet.Name,
                                                     wallet.Balance, wallet.Description, wallet.BasicCurrency, null, wallet.Guid));

                    // CurrentInfo.AddRecord(wallet);
                    _goToAccount.Invoke();
                }
            }
        }
コード例 #2
0
        public async void SubmitW()
        {
            WalletsHandler handler = new WalletsHandler();

            handler.Filename = @"../../../DataBase/Wallet/Wallets.json";
            var n = CurrentInfo.Customer.GetWalletByName(CurrentInfo.Wallet.Name);
            await handler.Change(n, n.Name);
        }
コード例 #3
0
        public void TestRemovingWallets()
        {
            //
            WalletsHandler walletsHandler = new WalletsHandler();
            var            filename       = @"../../../DataBase/Wallet/wallets.json";

            walletsHandler.Filename = filename;

            //
            walletsHandler.Remove("OwnerEmail", "Name");

            //
            Assert.NotNull(walletsHandler.Find("OwnerEmail", "changedName"));
        }
コード例 #4
0
        public void TestChangingWallets()
        {
            //
            var testCustomer = new Customer("Vasilii", "Poberezhnii", "*****@*****.**");
            var testName     = "wallet1";
            var testWallet   = new Wallet(testCustomer, testName, 0, "", "UAH");

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

            walletsHandler.Filename = filename;

            //

            walletsHandler.Change(testWallet, "changedName");


            //
            Assert.NotNull(walletsHandler.Find("OwnerEmail", "changedName"));
        }
コード例 #5
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);
        }