public static Documents GetById(int Id)
 {
     using (var context = new DocumentsContext())
     {
         Documents document = context.Documents.FirstOrDefault(d=> d.ID == Id);
         return document;
     }
 }
 public static List<Documents> GetAll()
 {
     using (var context = new DocumentsContext())
     {
         List<Documents> documents = context.Documents.ToList();
         return documents;
     }
 }
 public static bool Create(Documents document)
 {
     using (var context = new DocumentsContext())
     {
         context.Documents.Add(document);
         return context.SaveChanges() > 0;
     }
 }
 public static bool Update(Documents document)
 {
     using (var context = new DocumentsContext())
     {
         context.Documents.Attach(document);
         context.Entry(document).State = EntityState.Modified;
         return context.SaveChanges() > 0;
     }
 }
 public static IList<Documents> Search(string doc_num, string cust_name, string nonconformity)
 {
     using (var context = new DocumentsContext())
     {
         IList<Documents> documents = context.Documents
             .Where(d => d.DocNum == doc_num || d.CustName.Contains(cust_name) && d.Nonconformity.Contains(nonconformity)).ToList();
         return documents;
     }
 }
 public static bool Delete(int id)
 {
     using (var context = new DocumentsContext())
     {
         var asset = context.Documents.Find(id);
         context.Documents.Remove(asset);
         return context.SaveChanges() > 0;
     }
 }