Пример #1
0
 /// <summary>
 /// Deletes exacly one Symbol by id in Symbols table,
 /// deletes all the entries of the symbol in CompositesOf table
 /// </summary>
 /// <param name="id"></param>
 /// <returns>true false depending on success</returns>
 public bool DeleteExact(int id)
 {
     using (var db = new BlissBaseContext(testing))
     {
         Symbols sym = db.Symbols.Find(id);
         try
         {
             // Deletes the relations where the symbol is a component of
             // a composite symbol
             var compOf = new CompositeOfDAL();
             compOf.DeleteBySymbolID(id);
             // Sets the symbol as a standard type (Deletes it from
             // SymbolTypes table)
             var type = new SymbolTypeDAL();
             type.SetStandardForSymID(id);
             // Deletes the symbol from Symbols table
             db.Symbols.Remove(sym);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             Debug.WriteLine("Exception when remowing symbol: " + id);
             Debug.WriteLine(e.StackTrace);
             return false;
         }
     }
     return true;
 }