public async Task <IActionResult> SetCategoryAmount(CategoryAmount model) { var contract = new Contract { WalletName = User.GetWalletName(), WalletAddress = User.GetWalletAddress(), WalletPassword = model.WalletPassword }; var transaction = await _blockChainApi.SetAmountForCategory(contract, model.Category, model.Amount); if (transaction.Success) { for (var i = 0; i < 2; i++) { await Task.Delay(_appConfiguration.Value.AverageBlockTime); var receipt = await _blockChainApi.GetReceipt(transaction.TransactionId); if (receipt.Success) { break; } if (!string.IsNullOrEmpty(receipt.Error)) { return(JsonError(receipt.Error)); } } return(JsonSuccess(Constants.CategoryAmountSuccess)); } return(JsonError(Constants.Error)); }
private void btnTransfer_Click(object sender, RoutedEventArgs e) { bool isDecimal = decimal.TryParse(moveMoneyTextBox.Text.Replace("$", ""), out decimal moveAmount); if (isDecimal) { decimal total = Convert.ToDecimal(totalAmountText.Text.Replace("$", "")); string newTotal = (total - moveAmount).ToString("0.00"); totalAmountText.Text = "$" + newTotal; Helper.updateDBValue("Categories", new KeyValuePair <string, object>("RunningTotal", newTotal), new Dictionary <string, string>() { { "CategoryId", _categoryId.ToString() } }); CategoryAmount selectedCategory = (CategoryAmount)categoryAmountsComboBox.SelectedValue; decimal selectedTotal = Convert.ToDecimal(selectedCategory.RunningTotal); Helper.updateDBValue("Categories", new KeyValuePair <string, object>("RunningTotal", (selectedTotal + moveAmount).ToString("0.00")), new Dictionary <string, string>() { { "Name", selectedCategory.Name } }); //refresh the list with the correct amounts categoryAmountList = new ObservableCollection <CategoryAmount>(); var categoryAmountsDT = Helper.getDBData("Categories", new List <string>() { "Name", "RunningTotal" }, null, "GroupId ASC"); foreach (DataRow amount in categoryAmountsDT.Rows) { if ((string)amount["Name"] != _name) { categoryAmountList.Add(new CategoryAmount() { Name = amount["Name"].ToString(), RunningTotal = amount["RunningTotal"].ToString() }); } } categoryAmountsComboBox.DataContext = categoryAmountList; moveMoneyTextBox.Text = ""; MessageBox.Show(this, "Transfer was successful.", "Successful Transfer", MessageBoxButton.OK); } else { MessageBox.Show(this, "Move amount must be a decimal.", "Move Amount Error", MessageBoxButton.OK); } }