public void AddDocument(DocumentModel doc)
        {
            doc.Tables.Add(doc.HeadTable);
            Document dbDoc = new Document();

            using (var db = new practiceEntities())
            {
                db.Configuration.AutoDetectChangesEnabled = false;

                dbDoc.Acts = ConvertActsToDbActs(doc.Acts);
                dbDoc.Tables = ConvertToDbTables(doc.Tables);
                db.Documents.Add(dbDoc);
                db.ChangeTracker.DetectChanges();
                db.SaveChanges();

            }
        }
        public string ExportToExcel(DocumentModel document,string savePath)
        {
            savePath = savePath + Path.GetRandomFileName().Replace('.', 'a') + ".xlsx";
                myApp = new Excel.Application();
                myApp.Visible = false;
                myBook = myApp.Workbooks.Add();
                mySheet = (Excel.Worksheet)myBook.Sheets[1];
                var lastRow = mySheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row;

                WriteHeadTable(document.HeadTable, ref lastRow);
                WriteActs(document.Acts, ref lastRow);
                WriteTables(document.Tables, ref lastRow);

                mySheet.Columns.AutoFit();
                myBook.SaveAs(savePath, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                myBook.Close(false);
                myApp.Quit();
                return savePath;
        }