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); }
private void Handle(TransferBetweenAccountsCommand command) { if (IsTransferFromThisAccount(command)) { StartTransferToDestination(command); } else if (IsTransferToThisAccount(command)) { StartTranferFromSource(command); } }
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)); }
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); }
private bool IsTransferFromThisAccount(TransferBetweenAccountsCommand command) { return(Data.Name == command.Source); }
private bool IsTransferToThisAccount(TransferBetweenAccountsCommand command) { return(Data.Name == command.Destination); }