private void UndeleteByIdCmd(UndeleteById cmd) { // verify id valid if (!State.IdDeleted(cmd.Id)) { if (State.IdNotDeleted(cmd.Id)) { Sender.Tell(new UndeleteById_IdNotDeleted()); } else { Sender.Tell(new UndeleteById_IdNotFound()); } return; } IActorRef entityActor = ActorRefs.Nobody; if (State.IdsDeletedActive.Contains(cmd.Id)) { entityActor = Context.Child(cmd.Id); if (entityActor == ActorRefs.Nobody) { entityActor = CreateEntity(cmd.Id); } } // if inactive, activate if (entityActor == ActorRefs.Nobody && State.IdsDeletedInactive.Contains(cmd.Id)) { entityActor = CreateEntity(cmd.Id); var activatedId = new ActivatedId(cmd.Id); PersistAndTrack(activatedId, result => { ActivatedIdEvnt(result); }); } // undelete record var undeletedId = new UndeletedId(cmd.Id); PersistAndTrack(undeletedId, result => { UndeletedIdEvnt(result); entityActor.Forward(cmd); }); }
private void UndeletedIdEvnt(UndeletedId evnt) { State.UndeleteId(evnt.Id); }