public Result <IEnumerable <BlockchainEvent> > ImportEvents( TxAction action, Address senderAddress, Block block, Transaction tx, JObject actionDataObj) { using (var uow = NewUnitOfWork(UnitOfWorkMode.Writable)) { List <BlockchainEvent> events = new List <BlockchainEvent> { new BlockchainEvent { AddressId = senderAddress.AddressId, TxActionId = action.TxActionId, BlockId = block.BlockId, Fee = tx.ActionFee, Amount = 0, TransactionId = tx.TransactionId, EventType = EventType.Action.ToString() } }; senderAddress.AvailableBalance -= tx.ActionFee; if (tx.Status == TxStatus.Success.ToString()) { Result result = Result.Success(); switch (action.ActionType.ToEnum <ActionType>()) { case ActionType.TransferChx: result = _actionService.TransferChx( events, actionDataObj.ToObject <TransferChxData>(), uow, senderAddress); break; case ActionType.DelegateStake: result = _actionService.DelegateStake( events, actionDataObj.ToObject <DelegateStakeData>(), uow, senderAddress); break; case ActionType.ConfigureValidator: result = _actionService.ConfigureValidator( events, actionDataObj.ToObject <ConfigureValidatorData>(), uow, senderAddress); break; case ActionType.RemoveValidator: result = _actionService.RemoveValidator(events, uow, senderAddress); break; case ActionType.SetAssetCode: result = _actionService.SetAssetCode( events, actionDataObj.ToObject <SetAssetCodeData>(), uow); break; case ActionType.SetAssetController: result = _actionService.SetAssetController( events, actionDataObj.ToObject <SetAssetControllerData>(), uow); break; case ActionType.SetAccountController: result = _actionService.SetAccountController( events, actionDataObj.ToObject <SetAccountControllerData>(), uow); break; case ActionType.TransferAsset: result = _actionService.TransferAsset( events, actionDataObj.ToObject <TransferAssetData>(), uow); break; case ActionType.CreateAssetEmission: result = _actionService.CreateAssetEmission( events, actionDataObj.ToObject <CreateAssetEmissionData>(), uow); break; case ActionType.CreateAsset: result = _actionService.CreateAsset(events, uow, senderAddress, action); break; case ActionType.CreateAccount: result = _actionService.CreateAccount(events, uow, senderAddress, action); break; case ActionType.SubmitVote: result = _actionService.SubmitVote(events, actionDataObj.ToObject <SubmitVoteData>(), uow); break; case ActionType.SubmitVoteWeight: result = _actionService.SubmitVoteWeight( events, actionDataObj.ToObject <SubmitVoteWeightData>(), uow); break; case ActionType.SetAccountEligibility: result = _actionService.SetAccountEligibility( events, actionDataObj.ToObject <SetAccountEligibilityData>(), uow); break; case ActionType.SetAssetEligibility: result = _actionService.SetAssetEligibility( events, actionDataObj.ToObject <SetAssetEligibilityData>(), uow); break; case ActionType.ChangeKycControllerAddress: result = _actionService.ChangeKycControllerAddress( events, actionDataObj.ToObject <ChangeKycControllerAddressData>(), uow); break; case ActionType.AddKycProvider: result = _actionService.AddKycProvider( events, actionDataObj.ToObject <AddKycProviderData>(), uow); break; case ActionType.RemoveKycProvider: result = _actionService.RemoveKycProvider( events, actionDataObj.ToObject <RemoveKycProviderData>(), uow); break; default: result = Result.Failure("Unsupported action type."); break; } if (result.Failed) { return(Result.Failure <IEnumerable <BlockchainEvent> >(result.Alerts)); } } NewRepository <BlockchainEvent>(uow).Insert(events); NewRepository <Address>(uow).Update(senderAddress); uow.Commit(); return(Result.Success(events.AsEnumerable())); } }