public void DeleteStockEntryTest() { SQLStockRepository stockRepo = new SQLStockRepository(); string actual = stockRepo.DeleteStock(102674); Assert.AreEqual(1, actual); }
/// <summary>Deletes a stock entry</summary> public string DeleteStock(uint id) { string serverResponse; SQLStockRepository stockRepo = new SQLStockRepository(); serverResponse = stockRepo.DeleteStock(id); return(serverResponse); }
/// <summary>Occurs when an item is added or removed from the StockEntriesBound collection</summary> private void StockEntriesBound_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { try { LoggingService.Log("Collection changed", "Log.txt"); StockEntry stockChanged = new StockEntry(); SQLStockRepository stockRepo = new SQLStockRepository(); string serverResponse = ""; if (e.OldItems != null) { stockChanged = e.OldItems[0] as StockEntry; serverResponse = stockRepo.DeleteStock(stockChanged.ID); } if (e.NewItems != null) { stockChanged = e.NewItems[0] as StockEntry; serverResponse = stockRepo.AddStockEntry(stockChanged); uint stockID; if (uint.TryParse(serverResponse, out stockID)) { stockChanged.ID = stockID; serverResponse = "Stock entry inserted with ID of " + stockID; } } if (serverResponse != "") { Messages.Items.Insert(0, serverResponse); } } catch (Exception ex) { Messages.Items.Insert(0, ex.Message); LoggingService.Log(ex, "Log.txt"); } }