public IEnumerable <Document> GetDocuments() { using (var context = new MyCoopEntities()) { return(context.Documents.ToList()); } }
public string AddDocument(Document document) { using (var context = new MyCoopEntities()) { var newDoc = new Document { CreateTime = DateTime.Now, UpdateTime = DateTime.Now, Link = "/api/documents/" + document.Name, Name = document.Name, Reference = document.Reference }; context.Documents.Add(newDoc); context.SaveChanges(); return(newDoc.Name); } }