예제 #1
0
        /// <summary>Updates a stock entry</summary>
        public string UpdateStockEntry(StockEntry stock)
        {
            string             serverResponse;
            SQLStockRepository stockRepo = new SQLStockRepository();

            serverResponse = stockRepo.UpdateStockEntry(stock);

            return(serverResponse);
        }
예제 #2
0
        public void UpdateStockEntryTest()
        {
            SQLStockRepository stockRepo   = new SQLStockRepository();
            StockEntry         stockUpdate = new StockEntry();

            stockUpdate.ID                        = 1;
            stockUpdate.Exchange                  = "NYSE";
            stockUpdate.Symbol                    = "AEA";
            stockUpdate.Date                      = DateTime.Parse("13/1/2010");
            stockUpdate.Volume                    = 205500;
            stockUpdate.PriceOpen.Amount          = 4.42m;
            stockUpdate.PriceClose.Amount         = 4.42m;
            stockUpdate.PriceCloseAdjusted.Amount = 4.42m;
            stockUpdate.PriceHigh.Amount          = 4.42m;
            stockUpdate.PriceLow.Amount           = 4.42m;

            string actual = stockRepo.UpdateStockEntry(stockUpdate);

            Assert.AreEqual(1, actual);
        }
예제 #3
0
        /// <summary>Occurs when a value in the StockEntriesBound collection is changed</summary>
        private void StockEntriesBound_ItemPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            try
            {
                LoggingService.Log("Collection property changed", "Log.txt");

                StockEntry         stockChanged = new StockEntry();
                SQLStockRepository stockRepo    = new SQLStockRepository();
                string             serverResponse;
                uint stockID;

                stockChanged = sender as StockEntry;


                if (stockChanged.ID == 0)
                {
                    //Insert stock
                    serverResponse = stockRepo.AddStockEntry(stockChanged);

                    if (uint.TryParse(serverResponse, out stockID))
                    {
                        stockChanged.ID = stockID;
                        serverResponse  = "Stock entry inserted with ID of " + stockID;
                    }
                }
                else
                {
                    //Update stock
                    serverResponse = stockRepo.UpdateStockEntry(stockChanged);
                }

                Messages.Items.Insert(0, serverResponse);
            }
            catch (Exception ex)
            {
                Messages.Items.Insert(0, ex.Message);
                LoggingService.Log(ex, "Log.txt");
            }
        }