예제 #1
0
 /// <summary>
 /// Create new transaction for the expense.
 /// </summary>
 /// <param name="transactionData">transaction data</param>
 /// <returns>true if transaction saved successfully else false.</returns>
 public bool CreateTransaction(TransactionMembers transactionData)
 {
     object[] transactionInputData = new object[7];
     transactionInputData[0] = transactionData.ExpenseId;
     transactionInputData[1] = transactionData.AmountReturned;
     transactionInputData[2] = transactionData.AmountReturnedOn;
     transactionInputData[3] = transactionData.ReturnedBy;
     transactionInputData[4] = transactionData.ReceivedBy;
     transactionInputData[5] = transactionData.Description;
     transactionInputData[6] = userSession.CompanyId;
     return(DataLibrary.ExecuteQuery(ref transactionInputData, "bspCreateTransaction").Equals(0));
 }
예제 #2
0
        public ActionResult Create(TransactionViewModel transactionViewModel)
        {
            if (expenseRepository.CheckAmountBeyondLevel(transactionViewModel.AmountReturned ?? 0, transactionViewModel.SelectedExpense, transactionViewModel.AmountReturnedBy, transactionViewModel.AmountReceivedBy))
            {
                ModelState.AddModelError("AmountReturned", "Entered amount returned is more than to return.");
            }

            if (ModelState.IsValid)
            {
                TransactionMembers transactionMembers = new TransactionMembers
                {
                    AmountReturned   = transactionViewModel.AmountReturned.Value,
                    AmountReturnedOn = transactionViewModel.AmountReturnedOn.Value,
                    ReceivedBy       = transactionViewModel.AmountReceivedBy,
                    ReturnedBy       = transactionViewModel.AmountReturnedBy,
                    ExpenseId        = transactionViewModel.SelectedExpense,
                    Description      = transactionViewModel.Description
                };
                bool isSavedSuccessfully = false;
                using (this.expenseRepository)
                {
                    isSavedSuccessfully = this.expenseRepository.CreateTransaction(transactionMembers);
                }

                if (isSavedSuccessfully)
                {
                    return(this.RedirectToAction("Create", "Transaction"));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "There was an issue saving the transaction. Please try again.");
                    ReloadModelOnError(transactionViewModel, this.expenseRepository);
                    return(this.View("Create", transactionViewModel));
                }
            }
            else
            {
                ReloadModelOnError(transactionViewModel, this.expenseRepository);
                return(this.View("Create", transactionViewModel));
            }
        }