/// <summary> /// Updates a SymID's TypeIndicator code. Does not set type for a SymID /// only updates. /// </summary> /// <param name="symId"></param> /// <param name="code"></param> /// <returns>true or false depending on success</returns> public bool UpdateTypeForSymID(int symId, TypeCodes code) { var toUpdate = GetExactRowBySymID(symId); try { using (var db = new BlissBaseContext(testing)) { toUpdate.TypeIndicator = code; db.Entry(toUpdate).State = EntityState.Modified; db.SaveChanges(); return true; } } catch (Exception e) { Debug.WriteLine("An exception was thrown when trying to update TypeIndicator code for " + "symId: " + symId); Debug.WriteLine(e.StackTrace); return false; } }
/// <summary> /// Deletes a composite symbol and it's rows in /// CompositeOf table. Takes a CompositeSymbols /// row as inn parameter /// </summary> /// <param name="compSymbol"></param> /// <returns>true or false depending on success</returns> internal bool DeleteCompositeSymbolByRow(CompositeSymbols compSymbol) { if (compSymbol == null) { return false; } else { using (var db = new BlissBaseContext(testing)) { try { db.CompositeSymbols.Attach(compSymbol); db.Entry(compSymbol).State = EntityState.Deleted; db.SaveChanges(); return true; } catch (Exception e) { Debug.WriteLine("Exception when removing symbol: " + compSymbol.CompID); Debug.WriteLine(e.StackTrace); return false; } } } }
/// <summary> /// Deletes a SymID from SymbolTypes table and effectively /// sets it as standard /// </summary> /// <param name="symId"></param> /// <returns>true or false depending on success</returns> public bool SetStandardForSymID(int symId) { var toRemove = GetExactRowBySymID(symId); try { using (var db = new BlissBaseContext(testing)) { db.SymbolTypes.Attach(toRemove); db.Entry(toRemove).State = EntityState.Deleted; db.SaveChanges(); return true; } } catch (Exception e) { Debug.WriteLine("Exception thrown when trying to set symId: " + symId + " as standard SymbolType"); Debug.WriteLine(e.StackTrace); return false; } }