コード例 #1
0
 public IEnumerable <Document> GetDocuments()
 {
     using (var context = new MyCoopEntities())
     {
         return(context.Documents.ToList());
     }
 }
コード例 #2
0
 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);
     }
 }