static void Main(string[] args) { TradingSimulatorDbContext tradingSimulatorDbContext = new TradingSimulatorDbContext(); TradingSimulation tradingSimulation = new TradingSimulation(tradingSimulatorDbContext); tradingSimulation.RunTradingSimulation(); }
public void RunTradingSimulation() { TradingSimulation tradingSimulation = new TradingSimulation(dbContext); UserEntity seller = tradingSimulation.ChooseARandomUser(); UserEntity customer = tradingSimulation.ChooseARandomUser(); while (seller.Equals(customer)) { customer = tradingSimulation.ChooseARandomUser(); } UserAndSharesEntity sellerSharesToThUserEntity = tradingSimulation.SelectSharesAndUser(seller); SharesEntity sellerShares = tradingSimulation.ChooseShareskValue(sellerSharesToThUserEntity); UserAndSharesEntity customerSharesToThUserEntity = tradingSimulation.SelectStocksForUserObjectParameters(customer, sellerShares); int Price = tradingSimulation.RandomNumberGenerator((int)sellerShares.Price); int NumberOfShares = tradingSimulation.RandomNumberGenerator(sellerSharesToThUserEntity.AmountStocks); tradingSimulation.StockPurchaseTransaction(seller, customer, Price, NumberOfShares, sellerSharesToThUserEntity, customerSharesToThUserEntity); TransactionHistoryEntity transactionHistoryEntity = new TransactionHistoryEntity() { DateTimeBay = DateTime.Now, SellerId = seller.Id, CustomerId = customer.Id, AmountShare = NumberOfShares, Cost = Price }; TransactionService transactionService = new TransactionService(dbContext); transactionService.RegisterNewTransactionHistory(transactionHistoryEntity); }