public ActionResult Post(string address, decimal money) { if (BitcoinService.TransferBTC(BitcoinService.GetAccountWithMaximumBTC(BitcoinService.GetAllAccounts()), address, money)) { WalletService.UpdateBalanceFromAccount(address, BitcoinService); return(Ok($"Money {money} BTC send to {address} account")); } else { return(BadRequest($"Money {money} BTC not send to {address} account")); } }
public List <Account> GetAllWallets(BitcoinService service) { var accountsFromDB = Contex.Accounts.ToList(); List <Account> accountsFromBTC = service.GetAllAccounts().Select(x => new Account { Address = x.Key, Balance = x.Value }).ToList(); var newAccounts = GetNewAccounts(accountsFromDB, accountsFromBTC); Contex.Accounts.AddRange(newAccounts); Contex.SaveChanges(); UpdateBalanceAllAccounts(accountsFromBTC); return(Contex.Accounts.ToList()); }
public void UpdateBalanceFromAccount(string address, BitcoinService service) { decimal balanceFromBTC = service.GetAllAccounts().FirstOrDefault(x => x.Key == address.Replace(" ", string.Empty)).Value; UpdateBalanceFromAccount(address, balanceFromBTC); }