public async Task <int> Add(TransactionToSaveDto entity) { /*validation*/ var account = await _unitOfWork.Account.Get(entity.AccountId); if (account == null) { throw new System.Exception("Invalid account."); } var transactionType = await _TransactionTypeService.Get(entity.TransactionTypeId); if (transactionType == null) { throw new System.Exception("Invalid transaction type."); } if (entity.Amount <= 0) { throw new System.Exception("Invalid Amount."); } List <Transaction> transactions = new List <Transaction>(); foreach (var transactionDetail in transactionType.Details) { Transaction newTransaction = new Transaction { AccountId = (transactionDetail.AccountId == 0) ? entity.AccountId : transactionDetail.AccountId }; } return(1); }
public async Task <IActionResult> Post(TransactionToSaveDto transactionToSaveDto) { int id = await _serviceManager.Transaction.Add(transactionToSaveDto); return(Ok(id)); }