示例#1
0
        private void Handle(TransferBetweenAccountsCommand command)
        {
            Context.Log(x => x.Info("{Actor} - Sending the transfer to the destination account", Self.Path));

            //BecomeStacked(() => WaitConfirmation());

            Context.ActorSelection($"/user/domains/accounts/{command.Destination}").Tell(command);

            Context.System.Scheduler.ScheduleTellOnce(500, Self, command, Self);
        }
示例#2
0
 private void Handle(TransferBetweenAccountsCommand command)
 {
     if (IsTransferFromThisAccount(command))
     {
         StartTransferToDestination(command);
     }
     else if (IsTransferToThisAccount(command))
     {
         StartTranferFromSource(command);
     }
 }
示例#3
0
        private void StartTranferFromSource(TransferBetweenAccountsCommand command)
        {
            var result = Account.StartTransferFrom(command.Id, command.Source, command.Value, Data);

            if (result.IsOk)
            {
                Data = result.SucceededWith();
            }
            else
            {
                //TODO Samething as error 400
                //Sender.Tell()
            }

            //TODO point to persist

            Context.Log(x => x.Info("{Actor} - Transfer accepted", Self.Path));

            Sender.Tell(new TransferConfirmation(command.Id));
        }
示例#4
0
        private void StartTransferToDestination(TransferBetweenAccountsCommand command)
        {
            var result = Account.StartTransferTo(command.Id, command.Destination, command.Value, Data);

            if (result.IsOk)
            {
                Data = result.SucceededWith();
            }
            else
            {
                //TODO Samething as error 400
                //Sender.Tell()
            }

            //TODO point to persist

            Context.Log(x => x.Info("{Actor} - Transfer started", Self.Path));

            var transferActor = Context.ActorOf(TransferActor.Props(), command.Id.ToString());

            transferActor.Tell(command);
        }
示例#5
0
 private bool IsTransferFromThisAccount(TransferBetweenAccountsCommand command)
 {
     return(Data.Name == command.Source);
 }
示例#6
0
 private bool IsTransferToThisAccount(TransferBetweenAccountsCommand command)
 {
     return(Data.Name == command.Destination);
 }