示例#1
0
        //, string sourceName, string sourceTypeName, string authorFirstName, string authorLastName, string comment = "Default comment")
        public static Snippet CreateKb(string text, string pageOrLocation)
        {
            using (var db = new SnippetAppDB())
            {
                Snippet sp = new Snippet();
                sp.Text = text;
                sp.PageorLocation = pageOrLocation;
                db.Snippets.Add(sp);

                //Source sourcevar = new Source();
                //sourcevar.SourceName = sourceName;
                //db.Sources.Add(sourcevar);

                //Comments commentsvar = new Comments();
                //commentsvar.CommentsText = comment;
                //if (comment != "Default comment")
                //{

                //}
                //db.Comments.Add(commentsvar);

                //SourceType sourcetypevar = new SourceType();
                //sourcetypevar.SourceTypeName = sourceTypeName;
                //db.SoureTypes.Add(sourcetypevar);

                //Author authorvar = new Author();
                //authorvar.AuthorFirstName = authorFirstName;
                //authorvar.AuthorLastName = authorLastName;
                //db.Authors.Add(authorvar);

                db.SaveChanges();
                return sp;

            }
        }
示例#2
0
        public static Snippet CreateKb(string text, string pageOrLocation)//, string sourceName, string sourceTypeName, string authorFirstName, string authorLastName, string comment = "Default comment")
        {
            using (var db = new SnippetAppDB())
            {
                Snippet sp = new Snippet();
                sp.Text           = text;
                sp.PageorLocation = pageOrLocation;
                db.Snippets.Add(sp);

                //Source sourcevar = new Source();
                //sourcevar.SourceName = sourceName;
                //db.Sources.Add(sourcevar);

                //Comments commentsvar = new Comments();
                //commentsvar.CommentsText = comment;
                //if (comment != "Default comment")
                //{

                //}
                //db.Comments.Add(commentsvar);

                //SourceType sourcetypevar = new SourceType();
                //sourcetypevar.SourceTypeName = sourceTypeName;
                //db.SoureTypes.Add(sourcetypevar);

                //Author authorvar = new Author();
                //authorvar.AuthorFirstName = authorFirstName;
                //authorvar.AuthorLastName = authorLastName;
                //db.Authors.Add(authorvar);

                db.SaveChanges();
                return(sp);
            }
        }
示例#3
0
 public static Snippet GetSnippetByID(int TextID)
 {
     using (var db = new SnippetAppDB())
     {
         var snippetlist = db.Snippets.Where(a => a.TextID == TextID).FirstOrDefault();
         return(snippetlist);
     }
 }
示例#4
0
 public static Snippet DeleteKb(string text, string pageOrLocation)//, string sourceName, string sourceTypeName, string authorFirstName, string authorLastName, string comment = "Default comment")
 {
     using (var db = new SnippetAppDB())
     {
         Snippet sp = new Snippet();
         sp.Text           = text;
         sp.PageorLocation = pageOrLocation;
         db.Snippets.Remove(sp);
         db.SaveChanges();
         return(sp);
     }
 }
示例#5
0
 public static List <Snippet> SearchForSnippets(string query)
 {
     using (var context = new SnippetAppDB())
     {
         var    q  = context.Snippets.AsQueryable();
         string qs = query;
         {
             q = q.Where(x => x.Text.Contains(qs));
         }
         var result = q.ToList();
         return(result);
     }
 }
示例#6
0
 //everything below was added after 10.4 class
 public static Author[] GetAllAuthors(int authorID)
 {
     using (var db = new SnippetAppDB())
     { var authorlist = db.Authors.Where(a => a.AuthorID == authorID);
       return(authorlist.ToArray()); }
 }
示例#7
0
        public static List<Snippet> SearchForSnippets(string query)
        {
            using (var context = new SnippetAppDB())
            {
                var q = context.Snippets.AsQueryable();
                string qs = query;
                {
                    q = q.Where(x => x.Text.Contains(qs));

                }
                var result = q.ToList();
                return result;

            }
        }
示例#8
0
 public static Snippet GetSnippetByID(int TextID)
 {
     using (var db = new SnippetAppDB())
     {
         var snippetlist = db.Snippets.Where(a => a.TextID == TextID).FirstOrDefault();
         return snippetlist;
     }
 }
示例#9
0
 //everything below was added after 10.4 class
 public static Author[] GetAllAuthors(int authorID)
 {
     using (var db = new SnippetAppDB())
     { var authorlist = db.Authors.Where(a => a.AuthorID == authorID);
         return authorlist.ToArray();
     }
 }
示例#10
0
        //, string sourceName, string sourceTypeName, string authorFirstName, string authorLastName, string comment = "Default comment")
        public static Snippet EditKb(string text, string pageOrLocation)
        {
            using (var db = new SnippetAppDB())
            {
                Snippet sp = new Snippet();
                sp.Text = text;
                sp.PageorLocation = pageOrLocation;
                db.Snippets.Add(sp);
                db.SaveChanges();
                return sp;

            }
        }