public Event ValidateTransfer()
        {
            if (string.IsNullOrWhiteSpace(From.Id))
            {
                State = InitialTransferState.INVALID;
                return(ValidatorServiceEventFactory.BuildInvalidAccountEvent(TransactionId, ConstantStrings.ProcessAccountToError));
            }

            if (string.IsNullOrWhiteSpace(To.Id))
            {
                State = InitialTransferState.INVALID;
                return(ValidatorServiceEventFactory.BuildInvalidAccountEvent(TransactionId, ConstantStrings.ProcessAccountFromError));
            }

            if (Amount.Value <= 0)
            {
                State = InitialTransferState.INVALID;
                return(ValidatorServiceEventFactory.BuildInvalidAmountEvent(TransactionId, ConstantStrings.ProcessAmountError));
            }

            State = InitialTransferState.VALID;
            return(ValidatorServiceEventFactory.BuildTransferValidatedEvent(TransactionId));
        }
 private async Task ProcessFailure(MessageHeader header, Exception exception)
 {
     Event validationFailed = ValidatorServiceEventFactory.BuildOtherReasonValidationFailedEvent(header.TransactionId, exception);
     await eventProducer.ProduceAsync(validationFailed);
 }
 public Event CancelTransfer()
 {
     State = InitialTransferState.CANCELLED;
     return(ValidatorServiceEventFactory.BuildTransferCanceledEvent(TransactionId));
 }
 private async Task ProcessCancellationFailure(MessageHeader header, Exception exception)
 {
     Event cancelValidationEvent = ValidatorServiceEventFactory.BuildTransferNotCanceledEvent(header.TransactionId, exception);
     await eventProducer.ProduceAsync(cancelValidationEvent);
 }