예제 #1
0
        public ResponseModel <List <TransactionsModel> > CreateTransaction(TransactionsModel model)
        {
            if (_dateTimeHelper.GetDateTimeNow() < model.TransactionDate)
            {
                return(FailResponse(1, "TransactionDate cannot be greater than the current date"));
            }
            if (model.Amount == 0)
            {
                return(FailResponse(2, "Amount cannot be 0"));
            }
            var accountActive = _accountsRepo.IsAccountActive(model.AccountCode);

            if (!accountActive)
            {
                return(FailResponse(3, "Cannot post transactions to a closed account"));
            }

            _accountsRepo.AdjustAccountBalance(model.AccountCode, model.Amount);

            return(_repo.CreateTransaction(model));
        }