public AddTransactionViewModel CreateDepositViewModel(int accountId) { var account = _accountsRepository.GetOneByID(accountId); var oldBalance = _accountServices.GetBalanceOnAccount(account); var model = new AddTransactionViewModel() { Date = DateTime.Now, Type = "Credit", Operation = "Credit in Cash", FromAccountId = accountId, OldAccountBalance = oldBalance, }; model.ErrorMessageViewModel = new ErrorMessageViewModel() { ErrorMessage = "" }; return(model); }
public void CreateTransferThisBankToAccountTransaction(TransferThisBankTransactionViewModel model) { var targetAccount = _accountsRepository.GetOneByID(model.ToAccountId); var oldTargetBalance = _accountServices.GetBalanceOnAccount(targetAccount); var newTargetBalance = oldTargetBalance + model.Amount; var newTargetTransaction = new Transactions() { AccountId = model.ToAccountId, Date = model.Date, Type = "Credit", Operation = "Collection from Another Account", Amount = model.Amount, Balance = newTargetBalance, Symbol = model.Symbol, Bank = model.Bank, Account = model.FromAccountId.ToString(), }; _transactionsRepository.Create(newTargetTransaction); targetAccount.Balance = newTargetBalance; _accountsRepository.Update(targetAccount); }