public static void SaveDemo(IDocumentDemo d) { using (var db = CreateDataContext()) { var demo = db.Demos.FirstOrDefault(s => s.ID == d.ID) ?? new Demo(); demo.Title = d.Title; demo.DemoPath = d.Path; if (demo.ID == 0) { db.Demos.Add(demo); } db.SaveChanges(); } }
public static void SaveDocument(IDocumentDemo document) { using (var db = CreateDataContext()) { var doc = db.Documents.FirstOrDefault(s => s.ID == document.ID) ?? new Document(); doc.Title = document.Title; doc.DocumentPath = document.Path; if (doc.ID == 0) { db.Documents.Add(doc); } db.SaveChanges(); } }