public void Delete()
        {
            using(var context = new StockMarketContext())
            {
                var stock = context.AvailableStocks.Single(s => s.StockId == Stock.StockId);

                stock.PriceHistory.Clear();
                context.AvailableStocks.Remove(stock);
                context.SaveChanges();

                Publish(Stock, true);

                base.TryClose(true);
            }
        }
        public void Save()
        {
            this.Stock.CurrentPrice = Stock.DefaultPrice;

            using(var context = new StockMarketContext())
            {
                var stock = context.AvailableStocks.Find(Stock.StockId);

                if(stock == null)
                    context.AvailableStocks.Add(Stock);
                else
                {
                    var toUpdate = context.AvailableStocks.Single(s => s.StockId == Stock.StockId);
                    toUpdate.Name = Stock.Name;
                }

                context.SaveChanges();
                Publish(Stock);

                base.TryClose(true);
            }
        }