Ejemplo n.º 1
0
        public Transactions PostDeposit(TransactionsDepositDTO transactionsDTO)
        {
            Account accountDestination = _accountRepository.Get(new Object[] { transactionsDTO.AccountDestinationId });

            if (accountDestination == null || !accountDestination.Master)
            {
                throw new Exception("Aportes sao permitidos apenas para contas principais");
            }

            _transactionRepository.Begin();

            try
            {
                accountDestination.Money = accountDestination.Money + transactionsDTO.Money;
                _accountRepository.Save(accountDestination);

                Transactions transactions = new Transactions();
                transactions.AccountDestinationId = accountDestination.Id;
                transactions.Money             = transactionsDTO.Money;
                transactions.TransactionCode   = GeneratedCodeContribution.GetCode();
                transactions.TransactionTypeId = (int)TransactionsTypeEnum.DEPOSIT;
                transactions.Created           = DateTime.Now;

                _transactionRepository.Save(transactions);

                _transactionRepository.Commit();

                return(transactions);
            }
            catch (Exception ex)
            {
                _transactionRepository.RollBack();
                throw ex;
            }
        }