示例#1
0
        private async void RunTransaction_Click(object sender, ItemClickEventArgs e)
        {
            var selected = (QuickButton)e.ClickedItem;
            {
                var quickTransaction = selected.QuickTransaction;
                if (quickTransaction != null)
                {
                    var transaction =
                        QuickTransactionConverter.ToTransaction(new RegularTransactionFactory(), quickTransaction);

                    var isRequireInteraction =
                        QuickTransactionValidator.IsRequireInteractionForTransaction(quickTransaction);

                    if (isRequireInteraction)
                    {
                        OpenTransactionInEditMode(transaction);
                    }
                    else
                    {
                        try
                        {
                            await CreateTransactionFromTemplate(transaction);
                        }
                        catch (StorageException exception)
                        {
                            await ShowErrorDialog(exception);
                        }
                    }
                }
                else
                {
                    await CreateNewQuickTransaction();
                }
            }
        }
示例#2
0
        public void ToTransactionTest()
        {
            var categoryFactory = new RegularCategoryFactory();
            var accountFactory  = new RegularAccountFactory();

            var quickTransaction = new QuickTransaction
            {
                Account = accountFactory.CreateAccount(
                    "TestAccount", "Description", "USD"),
                Category     = categoryFactory.CreateCategory("TestAccount", "Description", 0L, null),
                Name         = "TestName",
                AskForWeight = false,
                AskForTotal  = false,
                Total        = 2.34m,
                Weight       = 1
            };

            var transaction =
                QuickTransactionConverter.ToTransaction(new RegularTransactionFactory(), quickTransaction);

            Assert.AreEqual(quickTransaction.Account, transaction.Account);
            Assert.AreEqual(quickTransaction.Category, transaction.Category);
            Assert.AreEqual(quickTransaction.Total, transaction.Total);
            Assert.AreEqual(quickTransaction.Weight, transaction.Weight);
            Assert.AreEqual(quickTransaction.Name, transaction.Name);
        }