/// <summary> /// This function saves all the stocks in the list into the saved /// stocks table in the database so the user who's id is attached to /// the stock can easily retrieve it later. /// </summary> /// <param name="stock_ids">List of all the stock ID's to save to the User's id</param> /// <param name="user_id">ID of the user to saved the stocks to</param> public void saveStocksForUser(List <int> stock_ids, int user_id) { using (var db = new stock_advisorDataContext(Program.ConnectionString)) { foreach (int id in stock_ids) { //create entry for each stock saved var entry = new SAVED_STOCK() { Stock_id = id, User_id = user_id }; db.SAVED_STOCKs.InsertOnSubmit(entry); try { db.SubmitChanges(); } catch (Exception e) { Console.WriteLine("Exception caught during saved_stock insert:\n"); Console.WriteLine(e.Message); } } } }
private void detach_SAVED_STOCKs(SAVED_STOCK entity) { this.SendPropertyChanging(); entity.USER_INFO = null; }
partial void DeleteSAVED_STOCK(SAVED_STOCK instance);
partial void UpdateSAVED_STOCK(SAVED_STOCK instance);
partial void InsertSAVED_STOCK(SAVED_STOCK instance);
private void attach_SAVED_STOCKs(SAVED_STOCK entity) { this.SendPropertyChanging(); entity.STOCK = this; }