Exemple #1
0
        private async void createTransaction_Click(object sender, System.EventArgs e)
        {
            _userRepository = new UserRepository();
            var userId = Domain.Constants.Constants.TestUserId;
            var user   = await _userRepository.GetById(userId);

            CreateTransactionFieldsValidation(out double amount, out string warningText, user);

            if (warningText != string.Empty)
            {
                warningLabel.Text = warningText;
                return;
            }

            var categoryId     = _lastSelectedCategory.Text;
            var helper         = new TransactionsHelper(new TransactionsRepository());
            var newTransaction = new Transaction
            {
                AmountDouble = amount,
                Description  = "Spending from Spendings page",
                UserId       = Domain.Constants.Constants.TestUserId,
                BalanceType  = spendBalance.SelectedItem.ToString(),
                CategoryId   = Guid.Parse(categoryId)
            };
            await helper.AddNewSpending(newTransaction, user, _userRepository);

            spendMoneyInput.Text = string.Empty;
            warningLabel.Text    = string.Empty;
            ReloadData();
        }