public void AddStockInList() { try { Stock newstock = new Stock(); newstock.Price = Convert.ToDouble(NewStockPrice); newstock.Quantity = Convert.ToInt64(NewStockQuantity); newstock.StockType = IsEquitySelected ? StockEnum.Equity : StockEnum.Bond; newstock.StockName = GenerateStockName(newstock.StockType); newstock.StockWeight = CalculateStockWeight(newstock.MarketValue); AllStocks.Add(newstock); /* After stock is added , Panel to add new stock is hidden, * Price and Quantity Textboxes are reset * Equity and Bond type checkboxes are also reset */ NewStockVisibility = Visibility.Hidden; IsEquitySelected = false; IsBondSelected = false; NewStockPrice = null; NewStockQuantity = null; NotifyPropertyChanged("NewStockVisibility"); NotifyPropertyChanged("StocksValue"); NotifyPropertyChanged("NewStockPrice"); NotifyPropertyChanged("NewStockQuantity"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void GetAllStocksCallback(IEnumerable <Stock> allStocks) { AllStocks.Clear(); foreach (Stock stock in allStocks) { AllStocks.Add(stock); } }