Ejemplo n.º 1
0
        private IPlayerTO CopyPlayerToPlayerTO(Player player)
        {
            var playerTo = new PlayerTO();

            playerTo.Name = player.GetName();

            var playerPortfolio   = player.GetPortfolio();
            var playerToPortfolio = new Dictionary <StockId, IStockPositionTO>();

            foreach (var portfolioKeyValuePair in playerPortfolio)
            {
                var stockOwned = portfolioKeyValuePair.Value.GetStockOwned();
                var stockTo    = new StockTO();
                stockTo.Id    = stockOwned.Id;
                stockTo.Value = stockOwned.Value;
                var stockPositionTo = new StockPositionTO();
                stockPositionTo.StockOwned    = stockTo;
                stockPositionTo.NumberOwned   = portfolioKeyValuePair.Value.NumberOwned;
                playerToPortfolio[stockTo.Id] = stockPositionTo;
            }

            playerTo.Portfolio = playerToPortfolio;
            playerTo.Cash      = player.GetCashValue();

            return(playerTo);
        }
Ejemplo n.º 2
0
        public IStockTO GetStockById(StockId stockId)
        {
            var stockTo = new StockTO();

            stockTo = (StockTO)_stocks[stockId].GetStockData();
            return(stockTo);
        }
Ejemplo n.º 3
0
        public IStockTO GetStockData()
        {
            var stockData = new StockTO();

            stockData.Id    = _id;
            stockData.Value = _value;
            return(stockData);
        }