public static bool deleteKind(Kind kind)
 {
     using (var _context = new DBReaderContext())
     {
         var dbkind = (from u in _context.tbKinds
                       where u.kind == kind.kind
                       select u).SingleOrDefault();
         _context.tbKinds.Remove(dbkind);
         _context.SaveChanges();
         return(true);
     }
 }
 public static bool deleteLink(Link link)
 {
     using (var _context = new DBReaderContext())
     {
         var dblink = (from u in _context.tbLinks
                       where u.ID == link.ID
                       select u).SingleOrDefault();
         _context.tbLinks.Remove(dblink);
         _context.SaveChanges();
         return(true);
     }
 }
 public static List <Kind> getListKind()
 {
     using (var _context = new DBReaderContext())
     {
         var kind = (from u in _context.tbKinds.AsEnumerable()
                     select u)
                    .Select(x => new Kind
         {
             ID   = x.ID,
             kind = x.kind,
         }).ToList();
         return(kind);
     }
 }
 public static bool updateKind(Kind kind)
 {
     try
     {
         using (var _context = new DBReaderContext())
         {
             _context.tbKinds.AddOrUpdate(kind);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 public static List <Link> getListLinks(string keyNote)
 {
     using (var _context = new DBReaderContext())
     {
         var kind = (from u in _context.tbLinks.AsEnumerable()
                     where u.note.Contains(keyNote)
                     select u)
                    .Select(x => new Link
         {
             ID   = x.ID,
             note = x.note,
             kind = x.kind,
         }).ToList();
         return(kind);
     }
 }
 public static bool addLink(Link link)
 {
     try
     {
         using (var _context = new DBReaderContext())
         {
             _context.tbLinks.Add(link);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 public static bool updateNote(Note note)
 {
     try
     {
         using (var _context = new DBReaderContext())
         {
             _context.tbNotes.AddOrUpdate(note);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 public static List <Note> getListNote()
 {
     using (var _context = new DBReaderContext())
     {
         var note = (from u in _context.tbNotes.AsEnumerable()
                     select u)
                    .Select(x => new Note
         {
             ID        = x.ID,
             filePath  = x.filePath,
             publishAt = x.publishAt,
             note      = x.note,
         }).ToList();
         return(note);
     }
 }
 public static Kind getKind(string kind)
 {
     using (var _context = new DBReaderContext())
     {
         var kindName = (from u in _context.tbKinds
                         where u.kind == kind
                         select u).ToList();
         if (kindName.Count == 1)
         {
             return(kindName[0]);
         }
         else
         {
             return(null);
         }
     }
 }
 public static Note getNote(string filePath)
 {
     using (var _context = new DBReaderContext())
     {
         var note = (from u in _context.tbNotes
                     where u.filePath == filePath
                     select u).ToList();
         if (note.Count == 1)
         {
             return(note[0]);
         }
         else
         {
             return(null);
         }
     }
 }