Exemplo n.º 1
0
        private void PopulateStockList(IEnumerable <RestApi.Portfolios.Stock> stocks)
        {
            if (OwnedStocks.Count == 0)
            {
                // Add entry to entire portfolio
                OwnedStocks.Add(new DescribedObject <StockViewItem>(_AllCompanies, "All Companies"));

                ViewParameter.Stock = _AllCompanies;
            }

            foreach (var stock in stocks.Select(x => new StockViewItem(x)))
            {
                var index = 1;
                for (var i = OwnedStocks.Count - 1; i >= 1; i--)
                {
                    if (stock.FormattedCompanyName.CompareTo(OwnedStocks[i].Value.FormattedCompanyName) > 0)
                    {
                        index = i + 1;
                        break;
                    }
                }

                OwnedStocks.Insert(index, new DescribedObject <StockViewItem>(stock, stock.FormattedCompanyName));
            }
        }
Exemplo n.º 2
0
        public void AddStockToPortfolio(string stockSymbol, decimal price, int numberOwned)
        {
            var ownedStock = new OwnedStock();

            ownedStock.GainStockOwnership(stockSymbol, price, numberOwned);

            OwnedStocks.Add(ownedStock);
        }