public static void RefreshTable(E_IStocksStore stocksStore, M_IStockDisplayTable stockDisplayTable) { StockCollection stockCollection = stocksStore.LoadStocks(); IEnumerable <M_StockWithPrice> stocksWithPrice = AddPriceToStock(stockCollection); IEnumerable <M_StockWithPriceAndValue> stocksWithPriceAndValue = CalculateGainAndCurrentValue(stocksWithPrice); M_StockWithPriceAndValue total = CalculateTotalCurrentValueAndGain(stocksWithPriceAndValue); List <M_StockDisplayData> displayLines = FormatDataForDisplay(stocksWithPriceAndValue, total); stockDisplayTable.Render(displayLines); }
public static void RefreshTable(E_IStocksStore stocksStore, E_IGainModel gainModel, E_IStockDisplayTable stockDisplayTable) { var stockCollection = stocksStore.LoadStocks(); stockDisplayTable.ClearList(); var stockPriceStockTotalPriceStockGains = gainModel.GetModel(stockCollection.EnumerateStocks()).ToList(); foreach (var s in stockPriceStockTotalPriceStockGains) { var stock = s.Stock; stockDisplayTable.AddItemToList(stock.Ticker, s.Price, stock.Shares, s.StockTotalPrice, s.StockGain); } stockDisplayTable.AddItemToList("------", "-", "-", "-"); stockDisplayTable.AddItemToList("Total", "-", "-", stockPriceStockTotalPriceStockGains.Sum(s => s.StockTotalPrice), stockPriceStockTotalPriceStockGains.Sum(s => s.StockGain)); }