public async Task <bool> Withdraw(decimal amountToWithdraw, string accountNumber, string user) { var accountBalanceRepo = new AccountStatementRepository(); var currentBalance = await accountBalanceRepo.GetCurrentBalance(user); var returnValue = false; var withdrawalRepo = new WithdrawalRepository(); var charges = Decimal.Multiply(amountToWithdraw, (decimal)0.10); var actualAmount = amountToWithdraw - (charges); currentBalance = currentBalance - charges; returnValue = await accountBalanceRepo.CreateSync(new AccountStatement { User = user, Debit = charges, CurrentBalance = currentBalance, TransactionDate = Helper.SetDateForMongo(DateTime.Now), Description = "parkSmartly transaction fee" }); if (returnValue) { currentBalance = currentBalance - actualAmount; await accountBalanceRepo.CreateSync(new AccountStatement { User = user, Debit = actualAmount, CurrentBalance = currentBalance, TransactionDate = Helper.SetDateForMongo(DateTime.Now), Description = "Actual withdrawn amount" }); } else { return(returnValue); } if (returnValue) { await withdrawalRepo.CreateSync(new Withdrawal { User = user, AccountNumber = accountNumber, AmountToWithdraw = amountToWithdraw, ActualAmount = actualAmount, DateWithdrawal = Helper.SetDateForMongo(DateTime.Now) }); } else { return(returnValue); } return(false); }
public async Task<bool> Withdraw(decimal amountToWithdraw, string accountNumber, string user) { var accountBalanceRepo = new AccountStatementRepository(); var currentBalance = await accountBalanceRepo.GetCurrentBalance(user); var returnValue = false; var withdrawalRepo = new WithdrawalRepository(); var charges = Decimal.Multiply(amountToWithdraw, (decimal)0.10); var actualAmount = amountToWithdraw - (charges); currentBalance = currentBalance - charges; returnValue = await accountBalanceRepo.CreateSync(new AccountStatement { User = user, Debit = charges, CurrentBalance = currentBalance, TransactionDate = Helper.SetDateForMongo(DateTime.Now), Description = "cordovaBuild transaction fee" }); if (returnValue) { currentBalance = currentBalance - actualAmount; await accountBalanceRepo.CreateSync(new AccountStatement { User = user, Debit = actualAmount, CurrentBalance = currentBalance, TransactionDate = Helper.SetDateForMongo(DateTime.Now), Description = "Actual withdrawn amount" }); } else { return returnValue; } if (returnValue) { await withdrawalRepo.CreateSync(new Withdrawal { User = user, AccountNumber = accountNumber, AmountToWithdraw = amountToWithdraw, ActualAmount = actualAmount, DateWithdrawal = Helper.SetDateForMongo(DateTime.Now) }); } else { return returnValue; } return false; }
async static Task Main(string[] args) { Console.WriteLine("Starting Oracle"); var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile("pkcscfg.json", optional: false, reloadOnChange: true) .AddCommandLine(args); IConfigurationRoot configuration = builder.Build(); Log.Debug("Building Config"); var conf = new NodeConfig(); configuration.GetSection("Node").Bind(conf); var pkcsConf = new PKCS(); configuration.GetSection("PKCS").Bind(pkcsConf); Log.Debug("NodeConfig created"); repository = new WithdrawInfoRepository(); var wdRepository = new WithdrawalRepository(); var connector = new CryptoConnector(conf.OracleETHAddres, conf.OracleBTCAddres, conf.ETHEndpoint, conf.BTCEndpoint, conf.Network); var miner = new Miner(new PeerListener(conf.ListenPort), new WalletRepository(), new BlockRepository(), new BalanceRepository(), new BookRepository(), new DepositRepository(), new OfferRepository(), new TransactionRepository(), wdRepository, new TradeRepository(), repository, connector, conf.ListenPort, true, 1000, true); ethConnector = new EthereumOracleConnector(conf.ETHEndpoint, conf.OracleETHAddres, pkcsConf.User, pkcsConf.EthKey); btcConnector = new BitcoinOracleConnector(conf.Network, conf.BTCEndpoint, pkcsConf.User, pkcsConf.BtcKey); if (conf.Reprocess) { Log.Information("Reprocessing withdraws: "); foreach (var wdid in await repository.ListToReprocess()) { Log.Information("Reprocessing withdraw: " + wdid); var wd = await wdRepository.Get(wdid); await ProcessWithdraw(wd); } } reader = miner.GetChainStream(); await miner.Start(true); WithdrawListener(miner, connector, conf); if (!string.IsNullOrEmpty(conf.SeedAddress) && conf.SeedPort > 0) { try { var seednode = new Peer(new TcpClient(conf.SeedAddress, conf.SeedPort)); miner.Connect(seednode); } catch (Exception e) { Log.Error(e.ToString()); throw; } } await Task.Delay(Timeout.Infinite); }
/// <summary> /// Initializes a new instance of the <see cref="WithdrawalService"/> class. /// </summary> /// <param name="withdrawalRepository">The withdrawal repository.</param> public WithdrawalService(WithdrawalRepository withdrawalRepository) : base(withdrawalRepository) { }
public WithdrawalController(WithdrawalRepository withdrawal) { _withdrawal = withdrawal; }