public async Task <TransactionModifyResult> Handle(TransactionModifyCommand command, CancellationToken cancellationToken) { TransactionModifyResult logicResult = new TransactionModifyResult(); try { TransactionFindArgs transactionFindArgs = new TransactionFindArgs { TransactionId = command.Args.TransactionId }; TransactionFindResult transactionFindResult = await _transactionRepository.FindAsync(transactionFindArgs) .ConfigureAwait(false); transactionFindResult.EnsureSuccess(); Transaction transaction = Transaction.Load(transactionFindResult.Result); transaction.Modify(command.Args); TransactionUpdateArgs transactionUpdateArgs = new TransactionUpdateArgs { Transaction = transaction }; TransactionUpdateResult transactionUpdateResult = await _transactionRepository.UpdateAsync(transactionUpdateArgs) .ConfigureAwait(false); transactionUpdateResult.EnsureSuccess(); logicResult.Result = transactionUpdateResult.Result; } catch (Exception ex) { logicResult.Exception = ex; } return(logicResult); }
public async Task <TransactionFindResult> FindAsync(TransactionFindArgs args) { TransactionFindResult logicResult = new TransactionFindResult(); try { TransactionDTO result = await _context.Set <Transaction>().Where(x => x.TransactionId == args.TransactionId) .Include(x => x.DebitAccount) .Include(x => x.CreditAccount) .Select(x => x.ToDTO()) .FirstOrDefaultAsync() .ConfigureAwait(false); logicResult.Result = result; } catch (Exception ex) { logicResult.Exception = ex; } return(logicResult); }