Ejemplo n.º 1
0
 //this Create a word and adds it to the dataBase
 public void CreateConnection(string docLocation, string wordText)
 {
     for (int i = 1; i <= new DataBaseManager().DatabasesCount(); i++)
     {
         string databaseLocation = new DataBaseManager().GetDatabaseLocation(i);
         //løsningen ville være at hente id på doc og word ned fra hver database
         Connection newC = new Connection
         {
             DocId  = new DocManager().GetDocId(docLocation, databaseLocation),//docId,
             WordId = new WordManager().GetWordId(wordText, databaseLocation)
         };
         try
         {
             using (var _reposertory = new DataBaseManager().GetDatabase(i))
             {
                 _reposertory.Connection.Add(newC);
                 _reposertory.SaveChanges();
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.ToString());
         }
     }
 }
 private void CreateDoc(Doc newDoc)
 {
     try
     {
         for (int i = 1; i <= new DataBaseManager().DatabasesCount(); i++)
         {
             using (var _reposertory = new DataBaseManager().GetDatabase(i))
             {
                 _reposertory.Doc.Add(newDoc);
                 _reposertory.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }