private void BuyPartOfTrasaction(TradeInfo tradeInfo) { decimal stockCost = stockTableRepository.GetCost(tradeInfo.Stock_ID); int customerStocks = stockClientTableRepository.GetAmount(tradeInfo.Customer_ID, tradeInfo.Stock_ID); decimal customerMoney = clientTableRepository.GetBalance(tradeInfo.Customer_ID); decimal transactionPrice = stockCost * tradeInfo.Amount; decimal newCustomerBalance = customerMoney - transactionPrice; int newCustomerStockAmount = customerStocks + tradeInfo.Amount; clientTableRepository.UpdateBalance(tradeInfo.Customer_ID, newCustomerBalance); editCleintStockService.Edit(new EditStockOfClientInfo { Client_ID = tradeInfo.Customer_ID, Stock_ID = tradeInfo.Stock_ID, AmountOfStocks = newCustomerStockAmount }); clientTableRepository.SaveChanges(); }