public async Task <Transaction> Handle(UpdateTransactionCommand request, CancellationToken cancellationToken) { var transaction = await _table.GetByIdAsync(request.TransactionId); transaction.Status = request.Status; transaction.ProceedDate = DateTime.UtcNow; return(await _table.UpdateAsync(transaction)); }
public async Task <Unit> Handle(TransferCommand request, CancellationToken cancellationToken) { var transaction = await _transactionsTable.GetByIdAsync(request.TransactionId); var writeOffAccount = await _accountsTable.GetAsync(transaction.WriteOffAccount, transaction.UserId); ValidateWriteOffAccount(writeOffAccount, transaction); var destinationAccount = await _accountsTable.GetByIdAsync(transaction.DestinationAccount); ValidateDestinationAccount(destinationAccount, transaction); writeOffAccount.Balance -= transaction.Amount; writeOffAccount.LastModified = DateTime.UtcNow; destinationAccount.Balance += transaction.Amount; destinationAccount.LastModified = DateTime.UtcNow; await _accountsTable.UpdateAsync(writeOffAccount); await _accountsTable.UpdateAsync(destinationAccount); return(Unit.Value); }