private bool ValidateLinkWalletOperation(LinkWalletOperationDto linkWalletOperation) { bool isValid = true; if (linkWalletOperation.Fee < 0) { isValid = false; _log.Warning("Link wallet operation with negative fee amount", context: linkWalletOperation); } if (string.IsNullOrEmpty(linkWalletOperation.CustomerId)) { isValid = false; _log.Warning("Link wallet operation without customer id", context: linkWalletOperation); } if (string.IsNullOrEmpty(linkWalletOperation.PrivateAddress)) { isValid = false; _log.Warning("Link wallet operation without private address", context: linkWalletOperation); } if (string.IsNullOrEmpty(linkWalletOperation.OperationId)) { isValid = false; _log.Warning("Link wallet operation without operationId", context: linkWalletOperation); } return(isValid); }
public async Task AddAsync(LinkWalletOperationDto operation) { using (var context = _contextFactory.CreateDataContext()) { var entity = LinkWalletOperationEntity.Create(operation); context.LinkWalletOperations.Add(entity); await context.SaveChangesAsync(); } }
public static LinkWalletOperationEntity Create(LinkWalletOperationDto operation) { return(new LinkWalletOperationEntity { Id = operation.OperationId, Direction = operation.Direction, Fee = operation.Fee, CustomerId = operation.CustomerId, PrivateAddress = operation.PrivateAddress, PublicAddress = operation.PublicAddress, Timestamp = operation.Timestamp }); }
public async Task ProcessWalletLinkingStateChangeCompletedEventAsync(LinkWalletOperationDto linkWalletOperation) { var isValid = ValidateLinkWalletOperation(linkWalletOperation); if (!isValid) { return; } linkWalletOperation.Direction = string.IsNullOrEmpty(linkWalletOperation.PublicAddress) ? LinkWalletDirection.Unlink : LinkWalletDirection.Link; linkWalletOperation.AssetSymbol = _tokenSymbol; await _linkWalletOperationsRepository.AddAsync(linkWalletOperation); }