public ActionResult <IncomeDto> DepositToBank([FromBody] IncomeDto dto) { var incomeCreationResult = _incomeService.Create(dto); _transactionService.CreateIncomeTransaction(incomeCreationResult); return(Ok(incomeCreationResult)); }
/// <summary> /// Saves the new income into the cache -validates the amount /// and gives an option to enter more data /// </summary> /// <param name="sender">Standard sender object</param> /// <param name="e">Standard event object</param> private void btnSave_Click(object sender, EventArgs e) { // If the amount is blank if (txtAmount.Text == "") { MessageBox.Show("The amount can not be blank", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } // Checks that the amount is in numbers else if (!txtAmount.Text.IsDouble()) { MessageBox.Show("The amount must be in numbers", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); txtAmount.Text = ""; } // Otherwise saves the new income else { var newIncome = new Income(decimal.Parse(txtAmount.Text), dtPick.Value, _incomeCategoryService.LoadById(Convert.ToInt32(cmbCategory.SelectedValue)), _paymentMethodService.LoadById(Convert.ToInt32(cmbPayment.SelectedValue)), txtDetail.Text); _incomeService.Create(newIncome); // Asks if more data is being entered DialogResult = MessageBox.Show("The entry was saved" + "\nDo you want to add another income? ", "Save successful", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (DialogResult != DialogResult.Yes) { Close(); } // If more data is being entered clears the user entered data for the new data else { // Puts the focus back to the top of the form and resets the selected values cmbCategory.Focus(); txtAmount.Text = ""; txtDetail.Text = ""; } } }
private void CreateNewIncome(DateTime dtCurrentSaveDate) { var newIncome = new Income(decimal.Parse(txtAmount.Text), dtCurrentSaveDate, Convert.ToInt32(cmbCategory.SelectedValue), Convert.ToInt32(cmbPayment.SelectedValue), txtDetail.Text); _incomeService.Create(newIncome); }