/// <summary> /// Created Address with optimistic lock /// </summary> /// <param name="repoQuery"></param> /// <param name="rpcClass"></param> /// <param name="walletId"></param> /// <param name="other"></param> /// <typeparam name="TBlockchainAddress"></typeparam> /// <returns></returns> public virtual async Task <ReturnObject> CreateAddressAsync <TBlockchainAddress>( IAddressRepository <TBlockchainAddress> repoQuery, IBlockchainRpc rpcClass, string walletId, string other = "") where TBlockchainAddress : BlockchainAddress { try { using (var walletRepository = VakapayRepositoryFactory.GetWalletRepository(DbConnection)) { var walletCheck = walletRepository.FindById(walletId); if (walletCheck == null) { return new ReturnObject { Status = Status.STATUS_ERROR, Message = "Wallet Not Found" } } ; } var resultsRPC = rpcClass.CreateNewAddress(other); if (resultsRPC.Status == Status.STATUS_ERROR) { return(resultsRPC); } var address = resultsRPC.Data; // TBlockchainAddress _newAddress = new TBlockchainAddress(); var resultDB = await repoQuery.InsertAddress(address, walletId, other); // //if (result.Status == Status.StatusError) //{ // return new ReturnObject // { // Status = Status.StatusSuccess, // Message = "Cannot Insert Address" // }; //} //update address into wallet db //wallet.WalletBusiness(VakapayRepositoryFactory); return(new ReturnObject { Status = resultDB.Status, Message = resultDB.Message }); } catch (Exception e) { return(new ReturnObject { Status = Status.STATUS_ERROR, Message = e.Message }); } }
/// <summary> /// Created Address with optimistic lock /// </summary> /// <param name="repoQuery"></param> /// <param name="rpcClass"></param> /// <param name="walletId"></param> /// <param name="other"></param> /// <typeparam name="TBlockchainAddress"></typeparam> /// <returns></returns> public override async Task <ReturnObject> CreateAddressAsync <TBlockchainAddress>( IAddressRepository <TBlockchainAddress> repoQuery, IBlockchainRpc rpcClass, string walletId, string other = "") { //return base.CreateAddressAsync(wallet, repoQuery, rpcClass, walletId, other); try { using (var walletRepository = VakapayRepositoryFactory.GetWalletRepository(DbConnection)) { var walletCheck = walletRepository.FindById(walletId); if (walletCheck == null) { return new ReturnObject { Status = Status.STATUS_ERROR, Message = "Wallet Not Found" } } ; VakacoinRpcObj = rpcClass as VakacoinRpc; var results = CreateNewAccount(walletId); // Create account and add account name to VakacoinAccount table if (results.Status == Status.STATUS_ERROR) { return(results); } return(new ReturnObject { Status = Status.STATUS_SUCCESS, Message = "Create vakacoin account success!" }); } } catch (Exception e) { return(new ReturnObject { Status = Status.STATUS_ERROR, Message = e.Message }); } }