public static void RestoreDocumentHistory(int id, DateTime newTime) { string userName = System.Environment.UserName; DocumentHistory history = databaseContext.DocumentHistories.Where(a => a.id == id).FirstOrDefault(); DocumentHistory restoredHistory = new DocumentHistory(history.DocumentID, history.DocumentBinary, newTime, userName, history.UserName); databaseContext.DocumentHistories.Add(restoredHistory); databaseContext.SaveChanges(); databaseContext = new PointDocumentationEntities(); }
public static void CreateDocumentHistrory(int id, string filePath, DateTime newTime) { byte[] file = File.ReadAllBytes(filePath); string userName = System.Environment.UserName; string fileName = filePath.Substring(filePath.LastIndexOf("\\") + 1); DocumentHistory entry = new DocumentHistory(id, file, newTime, userName, fileName); databaseContext.DocumentHistories.Add(entry); databaseContext.SaveChanges(); databaseContext = new PointDocumentationEntities(); }